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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Create release via API via powershell

I am trying to achieve similar result as in

My Bamboo version is 6.9.2 build 60911.
Here is the code:

First, I am getting all deployment environments attached to build plan via request:

Invoke-WebRequest -uri $($baseUrl + "/rest/api/latest/deploy/project/forPlan?planKey=$buildPlanKey") -Headers $authHeader -UseBasicParsing -ErrorAction Stop -Verbose;

Then, I select my deployment project id out of results to variable $deploymentId and check, if there is a release with my name present

Invoke-WebRequest -uri $($baseUrl + "/rest/api/latest/deploy/project/$deploymentId/versions") -Headers $authHeader -UseBasicParsing -ErrorAction Stop -Verbose;

If release with my name is not present - I wish to create it with following code

        $releaseData = @{            
planResultKey = $buildPlanKey            
name          = $BambooReleaseName        

$json = $releaseData | ConvertTo-Json;

try {            
Invoke-RestMethod -Method Post -Body $json -Uri $($url + "/rest/api/latest/deploy/project/$deploymentId/version.json") -Headers $headers -ContentType "application/json" -Verbose;        
$result = $_.Exception.Response.GetResponseStream();
$reader = New-Object System.IO.StreamReader($result);
$reader.BaseStream.Position = 0;

But, at the end I get this:

{"errors":["Please provide a valid plan key"],"fieldErrors":{}}

However, as you can see by previous code - I am using valid plan key to retrieve deployment project. Why this error pops up? What am I doing wrong?


1 answer

1 accepted

0 votes
Answer accepted

I found the reason - in json 

$releaseData = @{            
planResultKey = $buildPlanKey            
name          = $BambooReleaseName        

I need to pass valid build result, not build plan

So it should be 

$releaseData = @{            
planResultKey = ${bamboo.buildResultKey}            
name          = $BambooReleaseName        

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events