• Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      It's currently not possible to trigger a deployment project from a stage of a plan. Deployment projects can be triggered upon completion of a plan but if, for example, there is a plan with two stages when the second stage is manual, there is no way to trigger the deployment when the second stage completes.

      One solution can be breaking the stages into two different plans and passing artifacts to the second plan, or setting it as a child plan of the first plan if the manual run can be converted into an automated process but this is not the best or easiest solution.

            [BAM-13501] REST API for deployments

            Plan runners add on adds task to deploy or rollback releases as well as REST API
            https://marketplace.atlassian.com/plugins/com.mdb.plugins.planrunners/server/overview
            Hope this helps.

            Bhagyashree added a comment - Plan runners add on adds task to deploy or rollback releases as well as REST API https://marketplace.atlassian.com/plugins/com.mdb.plugins.planrunners/server/overview Hope this helps.

            Alexey Chystoprudov added a comment - operations67 , have you seen this page with some details about this API calls? https://developer.atlassian.com/display/BAMBOODEV/REST+API+deployment+triggers+for+Bamboo

            Nabru S added a comment -

            Ok, it was my mistake....

            it's working fine with Powershell now (without a dedicated JSON body )

            function global:new-BambooDeployment
            {
              
                $url = "http://bamboo/rest/api/latest/queue/deployment?environmentId=1234&versionId=5678"
                
             Invoke-RestMethod -Uri $url -Headers $Headers -Method post -ContentType "application/json"
            }
            

            Nabru S added a comment - Ok, it was my mistake.... it's working fine with Powershell now (without a dedicated JSON body ) function global: new -BambooDeployment { $url = "http: //bamboo/ rest /api/latest/queue/deployment?environmentId=1234&versionId=5678" Invoke-RestMethod -Uri $url -Headers $Headers -Method post -ContentType "application/json" }

            Nabru S added a comment -

            We are running Bamboo Version 5.12.

            I tried to trigger a deployment via

            /queue/deployment?expand

            How does it work correctly ? I use already a lot of REST API calls but this is not working.
            I found out that I have to user -Content application/x-www-form-urlencoded to perform a get.

            So how to perform a post correctly. I'm using Basic auth.

            Nabru S added a comment - We are running Bamboo Version 5.12. I tried to trigger a deployment via /queue/deployment?expand How does it work correctly ? I use already a lot of REST API calls but this is not working. I found out that I have to user -Content application/x-www-form-urlencoded to perform a get . So how to perform a post correctly. I'm using Basic auth.

            Was the intent of this ticket to implement only an API to trigger deployments? If so, the title is a little misleading and it is very unfortunate that numerous tickets have been closed as 'duplicate' that were requesting CRUD operations for deployment projects and environments.

            It would be invaluable if there were an API that allowed us to create environments, set permissions and add tasks.

            Bryan Custer added a comment - Was the intent of this ticket to implement only an API to trigger deployments? If so, the title is a little misleading and it is very unfortunate that numerous tickets have been closed as 'duplicate' that were requesting CRUD operations for deployment projects and environments. It would be invaluable if there were an API that allowed us to create environments, set permissions and add tasks.

            Note: You only need releaseTypeOption environmentId and promoteVersion in the request body - versionName, planKey, buildNumber and altToken are optional!

            Deleted Account (Inactive) added a comment - Note: You only need releaseTypeOption environmentId and promoteVersion in the request body - versionName , planKey , buildNumber and altToken are optional!

            Edit

            My code snippet above is was wrong..... Corrected code below:

            import java.io.*;
            import java.net.*;
            import org.apache.commons.codec.binary.Base64;
            
            // Bamboo deployment data
            String environmentId = "";
            String versionName   = "";
            String planKey       = "";
            String buildNumber   = "";
            String altToken      = "";
            
            // Application base URL
            String baseURL = "http://bamboo";
            System.out.println("Base URL : " + baseURL);
            
            // Basic authentication
            String authString = "user:pass".getBytes().encodeBase64().toString();
            System.out.println("Auth String : " + authString);
            
            // Resource
            String path = "/deploy/executeManualDeployment.action";
            System.out.println("Resource : " + path);
            
            // Request method
            String requestMethod = "POST";
            
            // Escape the double quotes in json string
            String payload = "environmentId="+environmentId+"&newReleaseBuildResult="+planKey+"-"+buildNumber+"&versionName="+versionName+"&releaseTypeOption=PROMOTE&promoteVersion="+versionName+"&save=Start+deployment&atl_token="+altToken;
            System.out.println("POST Data : " + payload);
            
            try {
                // Target URL of the resource to request
                URL url = new URL(baseURL + path);
            
                // A new connection is opened by calling the openConnection method of
                // the protocol handler for this URL.
                // 1. This is the point where the connection is opened.
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                // set connection output to true
                connection.setDoOutput(true);
                // Set request method
                connection.setRequestMethod(requestMethod);
            
                // Declare content type and authentication
                connection.setRequestProperty("Authorization", "Basic " + authString);
                connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            
                // 2. This is the point where you'll know if the connection was
                // successfully established. If an I/O error occurs while creating
                // the output stream, you'll see an IOException.
                OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
            
                // 3. Sending the data is conducted here. We established the
                // connection with getOutputStream
                writer.write(payload);
            
                // Closes this output stream and releases any system resources
                // associated with this stream. At this point, we've sent all the
                // data. Only the outputStream is closed at this point, not the
                // actual connection
                writer.close();
            
                // If there is a response code AND that response code is 200 OK, do
                // stuff in the first if block
                if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    // OK
                    System.out.println("Method : " + connection.getRequestMethod() + " - Successful!");
                    // Otherwise, if any other status code is returned, or no status
                    // code is returned, do stuff in the else block
                    connection.disconnect();
                } else {
                    // Server returned HTTP error code.
                    System.out.println("Method : " + connection.getRequestMethod());
                    System.out.println("Response Code : " + connection.getResponseCode());
                    System.out.println("Response Message : " + connection.getResponseMessage());
                    connection.disconnect();
                }
            } catch (MalformedURLException e) {
                System.out.println("MalformedURLException : " + e);
            } catch (IOException e) {
                System.out.println("IOException : " + e);
            }
            

            Deleted Account (Inactive) added a comment - Edit My code snippet above is was wrong..... Corrected code below: import java.io.*; import java.net.*; import org.apache.commons.codec.binary.Base64; // Bamboo deployment data String environmentId = ""; String versionName = ""; String planKey = ""; String buildNumber = ""; String altToken = ""; // Application base URL String baseURL = "http: //bamboo" ; System .out.println( "Base URL : " + baseURL); // Basic authentication String authString = "user:pass" .getBytes().encodeBase64().toString(); System .out.println( "Auth String : " + authString); // Resource String path = "/deploy/executeManualDeployment.action" ; System .out.println( "Resource : " + path); // Request method String requestMethod = "POST" ; // Escape the double quotes in json string String payload = "environmentId=" +environmentId+ "&newReleaseBuildResult=" +planKey+ "-" +buildNumber+ "&versionName=" +versionName+ "&releaseTypeOption=PROMOTE&promoteVersion=" +versionName+ "&save=Start+deployment&atl_token=" +altToken; System .out.println( "POST Data : " + payload); try { // Target URL of the resource to request URL url = new URL(baseURL + path); // A new connection is opened by calling the openConnection method of // the protocol handler for this URL. // 1. This is the point where the connection is opened. HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // set connection output to true connection.setDoOutput( true ); // Set request method connection.setRequestMethod(requestMethod); // Declare content type and authentication connection.setRequestProperty( "Authorization" , "Basic " + authString); connection.setRequestProperty( "Content-Type" , "application/x-www-form-urlencoded" ); // 2. This is the point where you'll know if the connection was // successfully established. If an I/O error occurs while creating // the output stream, you'll see an IOException. OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream()); // 3. Sending the data is conducted here. We established the // connection with getOutputStream writer.write(payload); // Closes this output stream and releases any system resources // associated with this stream. At this point, we've sent all the // data. Only the outputStream is closed at this point, not the // actual connection writer.close(); // If there is a response code AND that response code is 200 OK, do // stuff in the first if block if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { // OK System .out.println( "Method : " + connection.getRequestMethod() + " - Successful!" ); // Otherwise, if any other status code is returned, or no status // code is returned, do stuff in the else block connection.disconnect(); } else { // Server returned HTTP error code. System .out.println( "Method : " + connection.getRequestMethod()); System .out.println( "Response Code : " + connection.getResponseCode()); System .out.println( "Response Message : " + connection.getResponseMessage()); connection.disconnect(); } } catch (MalformedURLException e) { System .out.println( "MalformedURLException : " + e); } catch (IOException e) { System .out.println( "IOException : " + e); }

            Discovered that you can trigger a deployment a HTTP POST request... I copied the deployment action as a cURL command in the Chrome dev tools Network tab - see Rafael Sperafico's answer to How to trigger Bamboo deployment using API?. I stripped all the headers except "Content-Type" and passed in basic authentication:

            curl -D- -u user:pass -X POST 'http://bamboo/deploy/executeManualDeployment.action' -H 'Content-Type: application/x-www-form-urlencoded' --data 'environmentId=[ENVIRONMENT-ID]&newReleaseBuildResult=[PLAN-KEY]-[BUILD-NUMBER]&versionName=[RELEASE-NAME/NUMBER]&releaseTypeOption=PROMOTE&promoteVersion=[RELEASE-NAME/NUMBER]&save=Start+deployment&atl_token=[PASTE-YOUR-ALT_TOKEN-HERE]'
            

            You will need to follow the steps in How to trigger Bamboo deployment using API? to get your atl_token value for the cURL command. I'm currently running a JIRA Workflow custom script post function, allowing my developers to deploy from their JIRA issues:

            import java.io.*;
            import java.net.*;
            import org.apache.commons.codec.binary.Base64;
            
            // Bamboo deployment data
            String environmentId = "[ENVIRONMENT-ID]";
            String versionName   = "[RELEASE-NAME/NUMBER]";
            String planKey       = "[PLAN-KEY]";
            String buildNumber   = "[BUILD-NUMBER]";
            String altToken         = "[PASTE-YOUR-ALT_TOKEN-HERE]";
            
            // Application base URL
            String baseURL = "http://bamboo";
            System.out.println("Base URL : " + baseURL);
            
            // Basic authentication
            String authString = "user:pass".getBytes().encodeBase64().toString();
            System.out.println("Auth String : " + authString);
            
            // Resource
            String path = "/deploy/executeManualDeployment.action";
            System.out.println("Resource : " + path);
            
            // Escape the double quotes in json string
            String payload = "environmentId="+environmentId+"&newReleaseBuildResult="+planKey+"-"+buildNumber+"&versionName="+versionName+"&releaseTypeOption=PROMOTE&promoteVersion="+versionName+"&save=Start+deployment&atl_token="+altToken;
            System.out.println("POST Data : " + payload);
            
            try {
                // Target URL of the resource to request
                URL url = new URL(baseURL + path);
            
                // A new connection is opened by calling the openConnection method of
                // the protocol handler for this URL.
                // 1. This is the point where the connection is opened.
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                // set connection output to true
                connection.setDoOutput(true);
            
                // Declare content type and authentication
                connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                connection.setRequestProperty("Authorization", "Basic " + authString);
            
                // 2. This is the point where you'll know if the connection was
                // successfully established. If an I/O error occurs while creating
                // the output stream, you'll see an IOException.
                OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
            
                // 3. Sending the data is conducted here. We established the
                // connection with getOutputStream
                writer.write(payload);
            
                // Closes this output stream and releases any system resources
                // associated with this stream. At this point, we've sent all the
                // data. Only the outputStream is closed at this point, not the
                // actual connection
                writer.close();
            
                // If there is a response code AND that response code is 200 OK, do
                // stuff in the first if block
                if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    // OK
                    System.out.println("Method : " + connection.getRequestMethod() + " - Successful!");
                    // Otherwise, if any other status code is returned, or no status
                    // code is returned, do stuff in the else block
                    connection.disconnect();
                } else {
                    // Server returned HTTP error code.
                    System.out.println("Method : " + connection.getRequestMethod());
                    System.out.println("Response Code : " + connection.getResponseCode());
                    System.out.println("Response Message : " + connection.getResponseMessage());
                    connection.disconnect();
                }
            } catch (MalformedURLException e) {
                System.out.println("MalformedURLException : " + e);
            } catch (IOException e) {
                System.out.println("IOException : " + e);
            }
            

            I'll leave you smart people to it

            P.S. You could use a build plan to download and deploy your artifact instead. Build plans have better REST API support.

            Deleted Account (Inactive) added a comment - Discovered that you can trigger a deployment a HTTP POST request... I copied the deployment action as a cURL command in the Chrome dev tools Network tab - see Rafael Sperafico's answer to How to trigger Bamboo deployment using API? . I stripped all the headers except "Content-Type" and passed in basic authentication: curl -D- -u user:pass -X POST 'http: //bamboo/deploy/executeManualDeployment.action' -H 'Content-Type: application/x-www-form-urlencoded' --data 'environmentId=[ENVIRONMENT-ID]&newReleaseBuildResult=[PLAN-KEY]-[BUILD-NUMBER]&versionName=[RELEASE-NAME/NUMBER]&releaseTypeOption=PROMOTE&promoteVersion=[RELEASE-NAME/NUMBER]&save=Start+deployment&atl_token=[PASTE-YOUR-ALT_TOKEN-HERE]' You will need to follow the steps in How to trigger Bamboo deployment using API? to get your atl_token value for the cURL command. I'm currently running a JIRA Workflow custom script post function, allowing my developers to deploy from their JIRA issues: import java.io.*; import java.net.*; import org.apache.commons.codec.binary.Base64; // Bamboo deployment data String environmentId = "[ENVIRONMENT-ID]" ; String versionName = "[RELEASE-NAME/NUMBER]" ; String planKey = "[PLAN-KEY]" ; String buildNumber = "[BUILD-NUMBER]" ; String altToken = "[PASTE-YOUR-ALT_TOKEN-HERE]" ; // Application base URL String baseURL = "http: //bamboo" ; System .out.println( "Base URL : " + baseURL); // Basic authentication String authString = "user:pass" .getBytes().encodeBase64().toString(); System .out.println( "Auth String : " + authString); // Resource String path = "/deploy/executeManualDeployment.action" ; System .out.println( "Resource : " + path); // Escape the double quotes in json string String payload = "environmentId=" +environmentId+ "&newReleaseBuildResult=" +planKey+ "-" +buildNumber+ "&versionName=" +versionName+ "&releaseTypeOption=PROMOTE&promoteVersion=" +versionName+ "&save=Start+deployment&atl_token=" +altToken; System .out.println( "POST Data : " + payload); try { // Target URL of the resource to request URL url = new URL(baseURL + path); // A new connection is opened by calling the openConnection method of // the protocol handler for this URL. // 1. This is the point where the connection is opened. HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // set connection output to true connection.setDoOutput( true ); // Declare content type and authentication connection.setRequestProperty( "Content-Type" , "application/x-www-form-urlencoded" ); connection.setRequestProperty( "Authorization" , "Basic " + authString); // 2. This is the point where you'll know if the connection was // successfully established. If an I/O error occurs while creating // the output stream, you'll see an IOException. OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream()); // 3. Sending the data is conducted here. We established the // connection with getOutputStream writer.write(payload); // Closes this output stream and releases any system resources // associated with this stream. At this point, we've sent all the // data. Only the outputStream is closed at this point, not the // actual connection writer.close(); // If there is a response code AND that response code is 200 OK, do // stuff in the first if block if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { // OK System .out.println( "Method : " + connection.getRequestMethod() + " - Successful!" ); // Otherwise, if any other status code is returned, or no status // code is returned, do stuff in the else block connection.disconnect(); } else { // Server returned HTTP error code. System .out.println( "Method : " + connection.getRequestMethod()); System .out.println( "Response Code : " + connection.getResponseCode()); System .out.println( "Response Message : " + connection.getResponseMessage()); connection.disconnect(); } } catch (MalformedURLException e) { System .out.println( "MalformedURLException : " + e); } catch (IOException e) { System .out.println( "IOException : " + e); } I'll leave you smart people to it P.S. You could use a build plan to download and deploy your artifact instead. Build plans have better REST API support.

            We've tried that plugin but it keeps trying to pause the entire server whenever you create a template plan or update a plan that is derived from a template. We can't have the entire server paused multiple times a day.

            Oliver Eikenberry added a comment - We've tried that plugin but it keeps trying to pause the entire server whenever you create a template plan or update a plan that is derived from a template. We can't have the entire server paused multiple times a day.

            boris_alyurov_prcm added a comment - Oliver, Checkout this add-on for build templates: https://github.com/valenssoftware/bamboo-templatedplans-plugin https://marketplace.atlassian.com/plugins/org.valens.bamboo-templatedplans-plugin/server/overview

              Unassigned Unassigned
              ssetayeshfar Sepideh Setayeshfar (Inactive)
              Votes:
              193 Vote for this issue
              Watchers:
              152 Start watching this issue

                Created:
                Updated:
                Resolved: