This plugin provides a pipeline step to trigger Bamboo plans.
The plugin provides the buildBamboo step. Wrap it within a withCredentials to supply authentication information. You can also wrap it within a timeout block.
timeout(time: 600, unit: 'SECONDS') { // change to a convenient timeout for you
withCredentials([[$class : 'UsernamePasswordMultiBinding',
credentialsId : "bamboo-test-credentials",
usernameVariable: 'BAMBOO_USER',
passwordVariable: 'BAMBOO_PASS']]) {
buildBamboo(projectKey: "projectKey", planKey: "planKey", serverAddress: 'http://bamboo-server', 'username': env.BAMBOO_USER, 'password': env.BAMBOO_PASS)
}
}
See the Jenkinsfile in this repository for usage.
To trigger a build with parameters, pass a Map with your arguments:
buildBamboo(projectKey: "projectKey",
planKey: "planKey",
serverAddress: 'http://bamboo-server',
'username': env.BAMBOO_USER,
'password': env.BAMBOO_PASS,
propagate: False,
checkInterval: 120,
params: ["appVersion": "1.0.0", "buildNumber": env.BUILD_NUMBER])
The key names should correspond to the Bamboo variable names in the build plan. The plugin will prepend bamboo.variable prior to sending the request. For example, "appVersion" will be sent as "bamboo.variable.AppVersion=1.0.0". This is in accordance with the Bamboo REST documentation. From a shell script on the Bamboo server, you can access these variables as follows:
#!/bin/bash
echo 'Printing values passed into bamboo'
echo appVersion=$bamboo_appVersion
echo buildNumber=$bamboo_buildNumber
The checkInterval options sets how often to query the Bamboo server for the job status (In seconds, default: 30).
propagate determines if job failures cause the pipeline to halt.
The step uses a SynchronousNonBlockingStepExecution so it can run in the main thread without blocking execution. This is to prevent potentially long running jobs, which could take hours, from blocking an executor. The main work done by the plugin is to start the Bamboo plan, and then poll the target server every 30 seconds to monitor completion via the REST API.