Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to call a manual stage with costum variable API curl call Edited

Hello how can i call this from a curl call? 

The typical  

curl -X POST --user admin:admin "http://localhost:8085/rest/api/latest/queue/PROJ-PLAN?executeAllStages=true&bamboo.variable.myVariable=newValue" 

does not appear to work when trying to run a manual stage

curl -D- -u USERNAME:PASSWORD -p -H "Content-Type: application/json" -d '?stageB' -f -X PUT "https://COMPANY.atlassian.net/builds/rest/api/latest/queue/${bamboo_buildResultKey}"

I need to mimic with a curl call what we can do in the interface by setting a Variable when running a manual stage

 

1 answer

1 accepted

1 vote
Answer accepted
rsperafico Atlassian Team Aug 09, 2018

Hi @Daniel Mendes,

Please, run the following instead:

# Continue partially done build. Effectively, this method adds build to the build queue, so is not guarantied 
# that build would be executed immediately. Depending on currently executed builds and length of build queue,
# build may be executed when queue would be drained. Additional variables could be passed to this method only
# query parameters (variableName=variableValue). Variables defined in Bamboo as global variables or
# plan variables MUST be prefixed with bamboo.variable ie. bamboo.variable.myVariable=valueForMyVariable. When
# global or plan variables would be passed to this method, will override values valid for previous build
# execution (override).

# replace USERNAME and PASSWORD to authenticate against Bamboo
# replace bamboo.myVar=cURL in case you want to provide build with particular Bamboo variable
# replace http://localhost:8085 with Bamboo's Base URL
# replace PROJ-PLAN-1 with build result you would like to trigger manual stage
# repalce STAGENAME with the name of your stage, if name has space, replace it with plus sign, e.g:
#  Manual Stage, would result into Manual+Stage
curl -k -u USERNAME:PASSWORD \
     -H "Content-type: application/json" \
     -H "Accept: application/json" \
     -d 'bamboo.myVar=cURL' \
     -X PUT 'http://localhost:8085/rest/api/latest/queue/PROJ-PLAN-1?stage=STAGENAME&executeAllStages=true'
    
# consuming variable in build task (i.e Script task)
echo ${bamboo.myVar}

# response
cURL

Reference: https://docs.atlassian.com/atlassian-bamboo/REST/6.6.1/#d2e3903

Kind regards,

Rafael

Hi,

I tried that already, and it does not set the variable for the next stage.

If i start the pipeline it will set the variable, but continuing the pipeline when it is stopped on a manual stage does not set the Variable and in the metadata it is not there as well.

This works

 curl -k -u ${bambootoken} \
-d "bamboo.MYVAR=somethingsomething" \
-X POST "https://localhost:8085/rest/api/latest/queue/PRJ-P1"

but the goal is to continue a build stage not to trigger the plan so  

 curl -k -u ${bambootoken} \
-H "Content-type: application/json" \
-H "Accept: application/json" \
-d "bamboo.MYVAR=somethingsomething" \
-X PUT "https://localhost:8085/rest/api/latest/queue/PRJ-P1-88?stage=Deploy&executeAllStages=true"

is not setting the variable, it triggers the stage but the variable is not set and echo inside the plan returns the previous value not the one that is passed in the curl call.

rsperafico Atlassian Team Aug 10, 2018

Hi @Daniel Mendes,

In order to continue the build, you must specify the build number as mentioned in previous comment, e.g: PROJ-PLAN-1

-X PUT 'http://localhost:8085/rest/api/latest/queue/PROJ-PLAN-1?stage=STAGENAME&executeAllStages=true'

Kind regards,

Rafael

Hi Rafael I am sorry it was my mistake in writing the command, I tried with the build number the variable  passed in -d  is not taken into account using the PUT method.

Did you test this.... I am on ver 6.5 of Bamboo

The only thing that finally worked was to put it as a url query parameter thank you for pointing me to the documentation, in the end it helped

-X PUT 'http://localhost:8085/rest/api/latest/queue/PROJ-PLAN-1?stage=STAGENAME&executeAllStages=true&bamboo.variable.EXT_URL=http://myexternalurl'

 

rsperafico Atlassian Team Aug 10, 2018

Hi @Daniel Mendes,

Thank you for your update.

I am glad it is working for you now. If you also agree, please mark this answer as resolved so others facing the same issue will land to the correct answer / thread.

Kind regards,

Rafael

Like Steffen Opel _Utoolity_ likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

223 views 4 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you