How to access a shared artifact from a subsequent stage

Hi there, this problem has taken up far too much of my time for something which should be trivial. The documentation does not help in showing how an artifact is accessed, only how to define it as shared and how to set a shared artifact as a dependency.

I have two stages, stage one generates an artifact

Stage two has a script task that requires this artifact

The documentation (http://confluence.atlassian.com/display/BAMBOO40/Configuring+artifact+sharing+between+jobs) is pretty clear in saying that when creating the dependency on an artifact in a subsequent stage, the dependent artifact will be put in a destination directory relative to the build directory. I assume this means that it will be copied or linked to Stage 2's build directory in an arbitrary target directory.

So I naively tried to access it in Stage 2 by using

${bamboo.build.working.directory}/target/artifact_name

But this does not work. Does 'target' have to exist? I do not do a source code check out in Stage 2, so the build directory is theoretically empty. There are no errors, nothing to indicate I have done anything incorrectly.

I continued hunting around and found the Produced Artifacts page that just confused me even more. In Stage 1 it states that the shared artifacts are in:

$BAMBOO_HOME/data/artifacts/xxx-xxx/shared/build-yyyyy

Looking at the global bamboo variables that I have access to, there doesn't seem to be any obvious variable I can use to access this, so I have to construct it somehow.

What am I doing wrong here?

1 answer

This widget could not be displayed.

Does 'target' have to exist?

No.

${bamboo.build.working.directory}/target/artifact_name

But this does not work.

If you use target/artifact_name instead, does it work? Did you specify a Working Sub Directory for your script task?

Ok, I removed the destination directory, 'target'. And changed the way I access the artifact to be:

${bamboo.build.working.directory}/artifact_name

It still can not find the file.

I also print out the current working directory in my script and it is equal to ${bamboo.build.working.directory}, so I do not think there would be any difference in changing it from the absolute path ${bamboo.build.working.directory}/artifact_name to a relative path artifact_name.

I will try it anyway.

Hmm. Just thought of something. My artifact is a directory, it has 2 sub dirs and a bunch of files in each sub dir.

Could it be that the parent directory (artifact_name) isn't actually there, and its only the 2 sub dirs? I dont have access to the server's filesystem to check, but I will change the script to do a directory listing and print out what is available.

I will report back with the results when it finishes

Ok that was the problem. The artifact definition is */** (i.e. the contents) of the parent directory, and I assumed the parent directory was the artifact.

Apologies

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

222 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you