Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get 'atlas-run' to run Bamboo plugin in 4.4.5 rather than 3.3?

Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

When I test my plugin with atlas-run, Bamboo system information shows as version 3.3.


Bamboo system info also shows this plugin SDK info:

ATLAS_HOME=/opt/atlassian-plugin-sdk-4.2.10
ATLAS_VERSION=4.2.10

pom.xml:

<packaging>atlassian-plugin</packaging>
<properties>
<bamboo.version>4.4.5</bamboo.version>
<bamboo.data.version>3.2.2</bamboo.data.version>
<amps.version>4.2.10</amps.version>
</properties>

How do I tweak this so the plugin is tested in a Bamboo 4.4.5 instance rather than a 3.3 version?

20 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

Forgive my naive question, but have you cleaned up your 'target' directory? I recall a simple "mvn clean" should do the trick.

(It seems to me you have proper pom.xml configuration, so the only thing that comes to my mind is that you still have older Bamboo version somewhere in the depths of the 'target' directory)

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2013

Hi Ken,

I stand corrected - thank you for providing explanation why the scope must be 'provided'. I'll convert my first comment to an answer...

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2013

Piotr, Please see "https://answers.atlassian.com/questions/240923/how-to-get-the-git-url-from-within-a-bamboo-plugin": it must be 'provided' scope, otherwise, the class is loaded twice, and the 'instanceof' is checking one class against the other class, and failing since they appear to be two different classes, since they came from different class loaders.

Also, if you post your very first comment as the answer to the original quesiton about getting it run in bamboo 4.4.5, I can accept the answer so you get credit.

0 votes
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2013

1. Try doing that check against repo.getClass().getCanonicalName()

2. Use com.atlassian.bamboo.plugins.git.GitRepository#getAccessData to get the info you need for Git.

3. Use SVNURL.parseURIEncoded(com.atlassian.bamboo.repository.svn.SvnRepository#getSubstitutedRepositoryUrl) to get that info for Subversion

Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2013

Thanks, I'll try that out as soon as I get some other tasks finished.

Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 10, 2013

Sorry to be dense, but I think you've assumed I know more about java and plugin development than I actually do.

I implemented

if (repo.getClass().getCanonicalName() == "com.atlassian.bamboo.plugins.git.GitRepository")
{

GitRepository git = (GitRepository)repo;
GitRepositoryAccessData accessData = git.getAccessData();
}

and it compiles, but at runtime I get an error telling me I cannot cast 'repo' to GitRepository because it is already of type GitRepository.

So, I changed the code to


GitRepositoryAccessData accessData = repo.getAccessData();
return accessData.getRepositoryUrl();

since 'repo' is already of type GitRepository. But then it won't compile:

kwork/wkcopy/e2open_tasks/src/main/java/com/prcpo/bamboo/plugins/GetConfigTask.java:[135,44] cannot find symbol
symbol : method getAccessData()
location: interface com.atlassian.bamboo.repository.Repository

Because it seems to be invoking the getAccessData() method on the wrong class...

Can you be more explicit in how you visualized this would work? Thanks!

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 9, 2013

I no longer get the runtime error if I update my POM to use Bamboo 5.2.2 instead of 4.4.5, but...

Looks like the API in 5.2.2 still doesn’t work

Here’s the code:

private String GetPlanRepositoryUrl(){

for (RepositoryDefinition repoDef : taskContext.getBuildContext().getRepositoryDefinitions())

{

buildLogger.addErrorLogEntry("In GetPlanRepositoryUrl");

Repository repo = repoDef.getRepository();

buildLogger.addErrorLogEntry(repo.getClass().getName());

// here is where the API lets me down:

buildLogger.addErrorLogEntry(repo.getLocationIdentifier());

if (repo instanceof SvnRepository)

{

SvnRepository svn = (SvnRepository)repo;

return svn.getLocationIdentifier();

}

if (repo instanceof GitRepository)

{

GitRepository git = (GitRepository)repo;

return git.getLocationIdentifier();

}

}

buildLogger.addErrorLogEntry("No SVN or GIT repository found in plan");

return "";

}

Here’s what I see in the output:

error 10-Dec-2013 10:29:11 In GetPlanRepositoryUrl

error 10-Dec-2013 10:29:11 com.atlassian.bamboo.plugins.git.GitRepository

error 10-Dec-2013 10:29:11 Repository location information not supplied by plugin

error 10-Dec-2013 10:29:11 No SVN or GIT repository found in plan

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

import com.atlassian.bamboo.plugins.git;

I'd guess that you need to import full class name, like the following:

import com.atlassian.bamboo.plugins.git.GitRepository;

can you give a try to that?

----

or use * wildcard:

import com.atlassian.bamboo.plugins.git.*;

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

around line 11:

import com.atlassian.bamboo.repository.Repository;
import com.atlassian.bamboo.repository.RepositoryDefinition;
import com.atlassian.bamboo.repository.svn.SvnRepository;
import com.atlassian.bamboo.plugins.git;
import com.atlassian.bamboo.task.TaskContext;
import com.atlassian.bamboo.task.TaskException;

and around line 129

if (repo instanceof GitRepository)
{
GitRepository git = (GitRepository)repo;
return git.getLocationIdentifier();
}

command I am running:

$> atlas-run


(continued in next comment as comments are limited to 2000 characters)


0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

Hm... Please paste the contents of your

/kwork/wkcopy/e2open_tasks/src/main/java/com/prcpo/bamboo/plugins/GetConfigTask.java:

especially the contents around line/column: [11,35] (as this is where the "cannot find symbol" originated)

+ please paste the output of your maven command with which you try to build your plugin.

Can you provide these informations?

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

Executing: /opt/atlassian-plugin-sdk-4.2.10/apache-maven/bin/mvn com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:4.2.10:run -gs /opt/atlassian-plugin-sdk-4.2.10/apache-maven/conf/settings.xml
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building e2openTasks
[INFO] task-segment: [com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:4.2.10:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing amps-dispatcher:run
[WARNING] POM for 'com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git:pom:3.0.15:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.

[INFO] Compiling 20 source files to /kwork/wkcopy/e2open_tasks/target/classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

/kwork/wkcopy/e2open_tasks/src/main/java/com/prcpo/bamboo/plugins/GetConfigTask.java:[11,35] cannot find symbol
symbol : class git
location: package com.atlassian.bamboo.plugins

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

Because:

a.) that's what I found somewhere during my repeated searches of the internet...

b.) I don't know what I'm doing :-)

I removed that scope clause, still seeing:

Downloading: https://maven.atlassian.com/repository/public/com/atlassian/bamboo/plugins/atlassian-bamboo-plugin-git/3.0.15/atlassian-bamboo-plugin-git-3.0.15.pom
9K downloaded (atlassian-bamboo-plugin-git-3.0.15.pom)
[WARNING] POM for 'com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git:pom:3.0.15:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
Downloading: https://maven.atlassian.com/repository/public/com/atlassian/bamboo/plugins/atlassian-bamboo-plugin-git/3.0.15/atlassian-bamboo-plugin-git-3.0.15.jar

(note: I deleted ~/.m2/repository so that everything would download fresh, still got that warning about the invalid pom)

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

Hi Ken,

<scope>provided</scope>

Why (if at all!) do you use 'provided' scope when declaring dependency against bamboo-git-plugin? Shouldn't that dependency be scope-less in the pom.xml?

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 8, 2013

Any other ideas on this one, Piotr? I opened this as a separate question, but no takers so far, even with a bounty:

https://answers.atlassian.com/questions/240923/how-to-get-the-git-url-from-within-a-bamboo-plugin

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

I also tried an older version:

[INFO] Preparing amps-dispatcher:run
Downloading: https://maven.atlassian.com/repository/public/com/atlassian/bamboo/plugins/atlassian-bamboo-plugin-git/1.8.18/atlassian-bamboo-plugin-git-1.8.18.pom
6K
downloaded (atlassian-bamboo-plugin-git-1.8.18.pom)
[WARNING] POM for 'com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git:pom:1.8.18:provided' is invalid.

Its dependencies (if any) will NOT be available to the current build.
Downloading: https://maven.atlassian.com/repository/public/com/atlassian/bamboo/plugins/atlassian-bamboo-plugin-git/1.8.18/atlassian-bamboo-plugin-git-1.8.18.jar
<br< a="">>

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

I guess that would be the definitive source of info :-)

However, I think there is a deeper problem:

[WARNING] POM for 'com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git:pom:3.0.15:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.

So, even if I get the right 'import' statement from looking at the source, it seems the build is doomed...

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013
0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

Sorry, I don't do much plugin work, so this is new territory for me, and I'm having trouble finding the right docs...

I changed the pom to:

</dependency>
<dependency>
<groupId>com.atlassian.bamboo.plugins</groupId>
<artifactId>atlassian-bamboo-plugin-git</artifactId>
<version>3.0.15</version>
</dependency>
</dependencies>

but still getting

/kwork/wkcopy/e2open_tasks/src/main/java/com/prcpo/bamboo/plugins/GetConfigTask.java:[11,42] package com.atlassian.bamboo.repository.git does not exist

So, the interface must not parallel the svn interface... do you know where I can find the right documentation on how to write the equivalent code for git?

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

You shouldn't add it as a maven <plugin> into pom.xml. You should add it in the <dependencies> section as an another <dependency>...

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

That seems reasonable... but, the devil is in the details... I added the plugin after the existing maven-compiler-plugin entry:

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.bamboo.plugins</groupId>
<artifactId>atlassian-bamboo-plugin-git</artifactId>
<version>3.0.15</version>
</plugin>

I see the plugin downloaded, but get a strange error:

Downloading: https://maven.atlassian.com/repository/public/com/atlassian/bamboo/plugins/atlassian-bamboo-plugin-git/3.0.15/atlassian-bamboo-plugin-git-3.0.15.pom
9K
downloaded (atlassian-bamboo-plugin-git-3.0.15.pom)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git
POM Location: Artifact [com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git:pom:3.0.15]
Validation Messages:

[0] For dependency Dependency {groupId=org.eclipse.jgit, artifactId=org.eclipse.jgit, version=1.1.0.201109151100-r-ATLASSIAN-4, type=jar}: system-scoped dependency must specify an absolute path systemPath.


Reason: Failed to validate POM for project com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git at Artifact [com.atlassian.bamboo.plugins:atlassian-bamboo-plugin-git:pom:3.0.15]

0 votes
PiotrA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

Hm... Have you added dependency in your pom.xml to depend on bamboo-git-plugin? AFAIK GitRepository class is part of that plugin, where SvnRepository is part of Bamboo core facilities...

0 votes
Ken Wood
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 5, 2013

I could have sworn I did that, but, I did it again and also deleted .m2/repository and built from scratch, worked this time, thanks.

Now, if you can help with my other issue, that would be great! There is some code:

for (RepositoryDefinition repoDef : taskContext.getBuildContext().getRepositoryDefinitions())
{
Repository repo = repoDef.getRepository();
if (repo instanceof SvnRepository)
{
SvnRepository svn = (SvnRepository)repo;
return svn.getLocationIdentifier();
}

And, I need to check for a git repo being used. I tried the obvious of

if (repo instanceof GitRepository)
{
GitRepository git = (GitRepository)repo;
return git.getLocationIdentifier();
}

But, it fails to compile:

/kwork/wkcopy/e2open_tasks/src/main/java/com/prcpo/bamboo/plugins/GetConfigTask.java:[128,28] cannot find symbol
symbol : class GitRepository
location: class com.prcpo.bamboo.plugins.GetConfigTask

So I added:

import com.atlassian.bamboo.repository.svn.SvnRepository; //existing
import com.atlassian.bamboo.repository.git.GitRepository; //added this line

Surely there is corresponding code for git, but I haven't found it yet...

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events