I'm building a bamboo 3.3 plugin and would like to access an artifact of my build. I've been able to successfully see the ArtifactDefinitionContext using buildContext.getArtifactContext().getDefinitionContexts() however there doesn't seem to be a convenient way to grab a file from a bulds's artifacts.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That method offers the following signature and it's unclear how to access files within a builds artifacts.
public boolean retrieve(PlanResultKey planResultKey, ArtifactSubscriptionContext artifactSubscription, java.io.File buildWorkingDirectory)
Specifically what I'd like to do is read the clover.xml file generated on a successful build.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's because it's really meant to be used by plans other than the one that created the artifact. In your case, it's tricky because using it requires subscription context available in subscribing jobs, but not publishing jobs.
In your case, it will be simpler to access the file directly, e.g. com.atlassian.bamboo.fileserver.SystemDirectory#getArtifactDestinationDirectory
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good news is that the following worked. Worked in that it's able to find the build's artifacts.
for (ArtifactDefinitionContext artifact : buildContext.getArtifactContext().getDefinitionContexts()) { if(StringUtils.equals("Clover Report (System)", artifact.getName())) { File destinationDir = SystemDirectory.getArtifactDestinationDirectory(buildContext.getPlanResultKey(), artifact); File cloverXml = new File(destinationDir.getAbsolutePath() + destinationDir.separator + "site/clover/clover.xml"); logger.info(cloverXml.getAbsoluteFile() + " exists=" + cloverXml.exists()); } }
Unfortunately I incorrectly assumted that the clover.xml file was captured as part of the report. It appears that by default the clover.xml file is left in the working directory.
What's the best way to get access to the builds's working directory?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you running the plugin on agent side or server side? Is the clover.xml defined as a shared artifact or a regular artifact?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It can run agent side. I know that's required to access the working directory.
the clover.xml is not defined as a shared artifact. There is just an artifact which the clover plugin auto defines as follows:
Name: Clover Report (System)
Location: target/site/clover
Copy Pattern: **/*.*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it runs on agent side, you don't have to worry about ArtifactManager or the Artifact directory - since you were talking about artifacts, I assumed you meant server side. For a Job that creates artifacts, the artifact really start to exist on the server side.
In your case, you should just access the file directly in the build working directory. Try com.atlassian.bamboo.v2.build.BuildContextHelper#getBuildWorkingDirectory .
It may be an overkill in your case, but to get the same list of files that Bamboo uses to find the file, instantiate FileSet (have a look at com.atlassian.bamboo.build.artifact.AbstractArtifactManager#createFileSet) and do something like:
final DirectoryScanner directoryScanner = sourceFileSet.getDirectoryScanner(); directoryScanner.scan(); for (final String fileName : directoryScanner.getIncludedFiles()) {}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the help. I used the following and it worked fine:
File workingDirectory = BuildContextHelper.getBuildWorkingDirectory(buildContext); File cloverXml = new File(workingDirectory.getAbsolutePath() + File.separator + pathToColverFile);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I configured one-click clover integration on bamboo plan but no reports are generating.
Could someone suggest the correct pattern for clover artifact configuration. also please tell me possible reason for below error.
Failed to execute plugin 'Clover Results Collector' with error: No file matches the specified pattern:target/site/clover/**/clover.xml
Thanks
Gopi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can see the implementating classes AbstractArtifactManager, LocalArtifactManager, RemoteArtifactManager
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.