Get artifact file within job

I have a plan that consists of two jobs, the first running on Linux, the second on Windows. The second job needs the artifact created by the first job.

Right now my Windows job has 3 tasks: remove all files ("del *.tar.gz"), download the artifact, then a script do its real work.  I would like to combine those into 1 script task (because I have dozens of plans like these, and I'm tired of maintaining them all separately in Bamboo).  That means I need to somehow grab the artifact in my script.

Is there a way to do this?  Can a URL for the artifact be passed to the script or something?

Failing that, perhaps I can keep the artifact-download task in Bamboo, and then my script can delete all files except that artifact, but that requires knowing what that artifact file is called, something I'm not seeing a variable for.

Another solution would be to click the "Clean working directory after each build" box for this stage, but I don't like that because I often have to go look at the directory after a failed build and figure out what went wrong.  I wish there were a "Clean working directory before each build" option.

I'm running Bamboo version 5.12.2 build 51212, if there's something in a more recent version of Bamboo that would help, we're open to upgrading.

3 answers

This widget could not be displayed.

Jobs are run concurrently so that's not the way to do it.

You must move second job to second stage or move it to second plan. I

If you use stage you can use job artifact subscription.

If you use second plan you can use download artifacts task.

This widget could not be displayed.

Sorry, I get confused with the terminology - these two jobs are indeed in separate stages.  They are each the only job in their stage.

Can you say more about "artifact subscription"?  I couldn't find that terminology in the docs.  Currently I'm using the download artifacts task.

This widget could not be displayed.

Ok I think I understand your question better now.

In general you can't get artifact url in script task.

There are two good reasons for that:

  1. you can have more that one artifact and each artifact can be >1 file
  2. depending on artifact handler you can have in on Bamboo server or s3 (or some custom artifact storage maybe); so in theory in may be retrieved in different ways; plus you should solve authentication problem

If you could assume some artifact name as a standard then this one would be possible: https://jira.atlassian.com/browse/BAM-2357 (last comment)

 

Artifact subscription is called "dependency" in documentation. Take a look at https://confluence.atlassian.com/display/BAMBOO/Sharing+artifacts in section Sharing artifacts between jobs.

What you could do is to create this dependency in second job and put it into some specific directory. Then in script you could delete everything except that directory.

Trouble is I'm not sure if it makes things much simpler. You can have one task, but you need to create this dependency in job...

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published 6 hours ago in Marketplace Apps

The 7 hacks of highly successful automation

...there's anything I've learnt from working, it's that people are lazy! No offense to anyone reading this, but it's true and we can all admit it. The easier you make something for someone, the more...

39 views 0 8
Read article

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