How can I attach products of my build in Bamboo?

Hello,

I have a build that I run.  When it's done, the reports that it generates are outputted to a specific directory (say ~/builds/output/reports.)  What I'd like to do is attach the files inside to an individual build in Bamboo.

This is what I've tried so far.

  1. I went into my Stages & Jobs area and clicked on the Artifacts tab at the top.  Then I created an artifact (specifying the name and the directory of its location.)  When I re-ran my build, I did not see any of the HTML and XML files attached...
  2. This time around I created an another job that I put to run right after the first one.  Again, I tried the same thing of going to the Artifacts area and specifying what I want and I did not see the attached XML and HTML files...

I tried a relative and an absolute path, no go.  What am I doing wrong?

The goal here is to have a single place where this information is kept so that other members of my group can look at them.

2 answers

1 accepted

1 vote

Hello Andrew,

Thank you for your question.

  • The location is relative to the build directory. Do not use the absolute path to refer to the location.

Please, refer to Configuring a job's build artifacts for further information.

Alternatively, if you want to use a location that is outside your build working directory, you could to the following:

# lets use the following as build working directory
/atlassian/bamboo-home/xml-data/build-dir/PROJ-PLAN-JOB1
 
# you have a file in /atlassian/foo/bar.txt you want to use as artifact, then configure the location as per following:
Location: ../../../../foo
Copy pattern: bar.txt

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Would it make more sense to just have a script that copies the generated files to the build area after the build is run?

Hello Andrew, Thank you for your question. The is no problem on creating an Script /SCP task in order to copy files from one place to another. There issue in here is that only you will know what will be happening, Bamboo will not have knowledge of the artifact generated nor the one to be used. You will be the one managing the copying files. If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired. Thank you for your understanding. — Kind regards, Rafael P. Sperafico Atlassian Support

Hello Rafael, This is the new issue that I have: bash: /opt/automated_testing/copy_report.sh: No such file or directory Which I consider to be bizarre, since I can run other scripts out of automated_testing and the script is in fact located there. As for only me knowing this, after I'm done, this will all go into the local wiki on the topic, so that others will know and it's ok if Bamboo is not cognizant of every step.

Hello Andrew, Please, make sure the file is located under "/opt/automated_testing/copy_report.sh" and start with something simple just to make sure your script is being located by Bamboo. After that, start to build up the script you want. ============ #!/bin/sh echo "hello, world" ============ Are you adding this "copy_report.sh" to a Script task or are you adding it as a Command Capability to the Bamboo agent is running this build? Please, refer to the following for further information: * https://confluence.atlassian.com/display/BAMBOO/Script * https://confluence.atlassian.com/display/BAMBOO/Custom+command+executable Please, make sure you the script is located under the same agent box where the build is running from. If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired. Thank you for your understanding. — Kind regards, Rafael P. Sperafico Atlassian Support

Hello Rafael, This is interesting. I have two jobs. Both of them are running scripts. However, when I ran the command pwd in the first one, it retrieved the path that's found on the target execution machine (where the test is supposed to run.) When I ran the command pwd in the second one, it retrieved the path that's found on the server that controls the Bamboo jobs! In this case, of course that it can't run the copy instruction that I wanted to run! What could possibly cause this? And how do I change it back?

Hello Andrew, Thank you for your question. A Bamboo job is a single build unit within a plan. One or more jobs can be organised into one or more stages. The jobs in a stage can all be run at the same time, if enough Bamboo agents are available. A job is made up of one or more tasks. Every job has its own build working directory and this is not something you can change or configure. Please, refer to https://confluence.atlassian.com/display/BAMBOO/Jobs+and+tasks for further information. If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired. Thank you for your understanding. — Kind regards, Rafael P. Sperafico Atlassian Support

Ok, I didn't know that. Thanks for explaining it to me.

0 vote

Hello Andrew,

Thank you for your question.

Based on the description you have provided, it seems you are not giving the correct location to where your generated files are located in the build directory.

When running a build in Bamboo, files will be created under the build directory (In case check the build directory by opening up your build log, second line):

simple	19-Dec-2014 14:53:25	Build Project - Plan - Default Job #1 (PROJ-PLAN-JOB1-1) started building on agent Default Agent
simple	19-Dec-2014 14:53:25	Build working directory is <bamboo-home>/xml-data/build-dir/PROJ-PLAN-JOB1

When creating an artifact, Bamboo will start looking in the build working directory. Please, refer to Locating important directories and files for further information.

Lets take the following example:

Create a Project/Plan and add a Script task as per following:

# Windows
md foo
echo "foo-bar" > foo/bar.txt
# Linux
mkdir foo
echo "foo-bar" > foo/bar.txt

As a result, I would have the following in the build working directory:

<bamboo-home>/xml-data/build-dir/PROJ-PLAN-JOB1/foo/bar.txt

In order to generate the Artifact using "bar.txt", you should proceed as per following:

Name: <name-of-your-choice>
Location: foo
Copy pattern: bar.txt
[x] Shared

The next time you run this build, the Artifact above will be available under the "Build Summary" and "Artifacts" tab.

Please, refer to Sharing artifacts for further information.

If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.

Thank you for your understanding.

Kind regards,
Rafael P. Sperafico
Atlassian Support

Hi, thanks for such a quick reply. One quick question, does the location (in your example "foo") matter if it's an absolute one? Say /home/user/build/version/stuff?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,575 views 0 6
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