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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,373
Community Members
 
Community Events
176
Community Groups

Get shared artifact location by variable

Hello,

 

I need to upload the zipped artifact file from a .NET project build to Veracode, for security vulnerability scanning. To do this I have to define the shared artifact location with a variable in the script. The absolute path for the  shared artifact location is like that:

 

 C:\bamboo-home\shared\artifacts\plan-12345678\shared\build-00099\App-Zip-File\Name.Of.Solution.zip

 

The problem with this file path is the numbered plan and the numbered build. I couldn't find how Bamboo defines the numbers of the plans. To find the location of the zipped file, I had to search by the solution name. After the build was finished, the build working directory would be deleted, and the artifacts would be copied to the shared directory, but the Key of the plan is not used, it's this number that is used and I can't understand how it is generated. All I can find in Bamboo is the Key of the plan. To pass the file path to veracode, I need to have variables to get the plan number and build number. 

 

Can anyone assist, please?

 

Thank you.

1 answer

Hey @Pavlos Parcharidis

If you are looking to find the place the file is located you can do the following:

  • Add a new stage to your Plan. Make sure the stage runs AFTER the artifact is created/built
  • Add a script task to the new Stage that will run the following API request and output the location:
  • #!/bin/bash
    planKey=${bamboo_planKey}
    buildNumber=${bamboo_buildNumber}
    stageName=<THE PAST STAGE KEY THAT CREATED THE ARTIFACT>
    folder_number=$(curl -s -k -u admin:admin -H 'Accept: application/json' https://bamboo.mydomain.net/rest/api/latest/result/${planKey}-${stageName}-${buildNumber}?expand=results.result.artifacts | jq -r '.logFiles[] | split("/") | last| split("-")[1]')

    echo "The location is <bamboo-home>/shared/artifacts/plan-${folder_number}/${stageName}/build-${buildNumber}/<artifact_name>..."
  • You can even create a text file with the content you want and configure a Variable task to proceed with the next steps
  • It is always recommended to use a Personal Access Token instead of a username/password.

Apparently, as you are running Windows, you might have to adjust the script to PowerShell (or you can use cygwin or enable WSL.

More on the API: https://developer.atlassian.com/server/bamboo/bamboo-rest-resources/#build-service----all-builds

 

Regards,

Eduardo Alvarenga
Atlassian Support APAC

Hi @Eduardo Alvarenga ,

 

Many thanks for such a prompt and detailed response! I will try your solution and get back to you.

 

Regards,

Pavlos

Thank you @Pavlos Parcharidis please don't forget to accept the answer if it suits you :-)

Hi @Eduardo Alvarenga ,

 

Thanks again for providing such a complete answer. Unfortunately, I can't confirm if this solution works, as I couldn't convert your solution to a working powershell solution.

 

I had to follow a simpler path in the end, by downloading the artifact to a folder, and then uploading to Veracode from that folder.

 

I'm not sure if I should accept your answer as the solution. Just asking for other members looking into this post.

 

Kind Regards,

Pavlos

Thank you for the feedback @Pavlos Parcharidis. I have shown one solution that works for your case. There are possibly other solutions (like yours) that are not bound to the technical description.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events