You are not logged in. Click here to log in.

codebeamer Application Lifecycle Management (ALM)

Search In Project

Search inClear

Tags:  not added yet

Introduction

codeBeamer can be configured to start a build in Jenkins as part of a workflow and receive results of that build using simple scripts. The general approach is to configure codeBeamer to trigger the build in Jenkins and to configure the Jenkins build to provide feedback to codeBeamer.

The build will be triggered as part of a workflow executing a Groovy script, Jenkins will provide updates by sending back the build URL and updating the status of the item according to the build status.


Configuration

codeBeamer

The tracker you want to use to trigger the build should have status values representing Waiting, Running and Completed builds and transitions from Waiting to Running to Succesul.

Additionally a Wiki Link custom field that will be populated with the build URL needs to be defined.


To configure the workflow adjust the parameters in the triggerJenkinsBuild.groovy script used to trigger the build.

Variable Description

jenkinsUrl
URL of the Jenkins server to connect to.

jenkinsUser
User name to be used to log-in to Jenkins.

jenkinsPassword
Password or token used to authenticate with Jenkins.

jenkinsBuild
Name of the build to trigger in Jenkis.

jenkinsBuildToken
Token configured in Jenkins for remote triggering of the build.

linkField = "cIBuild"
Name of the field that should be used to track the URL of the Jenkins build converted to camelCase (Example: Name "CI Build" should be converted to cIBuild")

runningStatus
ID of the status value that should be used to indicate a build is running.
successStatus
ID of the status value that should be used to indicate a build has completed.


Once the parameters have been adjusted, deploy the script to <CBInstall>/tomcat/webapps/cb/config/scripts/workflow.

After deploying the script add an "Execute a custom script" action to the transition into the "Waiting" state with [triggerJenkinsBuild.groovy] as Script path,

Jenkins

First of all make sure remote building is enabled for the build you want to trigger from codeBeamer and the "Authentication Token" does match what you configured in the script.



Then add the parameters required by the integration script to the Jenkins build:

  • cbUrl (String)
  • cbId (String)
  • linkField (String)
  • cbRunningStatus (String)
  • cbSuccessStatus (String)
  • cbToken (Credentials)
Parameters are case-sensitive, make sure to use the right capitalization.

Use an "Execute Windows batch" build command to notify codeBeamer once the build is started. Executing a shell script on Linux will work with a similar script, but escaping of the script will have to be adjusted.

@curl --fail -X PUT %cbUrl%/rest/item ^
-H "Authorization: %cbToken%" ^
-d "{\"uri\":\"/item/%cbId%\",\"status\": {\"id\":%cbRunningStatus%},\"%cbLinkField%\":\"[%BUILD_URL%]\"}"

Add the "Post-build tasks plug-in" to Jenkins and add a Post build task to trigger sending back results after build completion with following command.

@curl --fail -X PUT %cbUrl%/rest/item ^
-H "Authorization: %cbToken%" ^
-d "{\"uri\":\"/item/%cbId%\",\"status\": {\"id\":%cbSuccessStatus%}}"

The same command with adjusted escaping will work on Linux.

Triggering of the Build from Jenkins

When the build is started from codeBeamer all relevant parameters including credentials for codeBeamer are passed from codeBeamer to Jenkins.


To support triggering the build from Jenkins, take the configuration values from you triggerJenkinsBuild.groovy script and use them as defaults for the following parameters in Jenkins:

  • cbUrl (String)
  • cbId (String)
  • linkField (String)
  • cbRunningStatus (String)
  • cbSuccessStatus (String)

The cbToken parameter has to be replaced with a credentials binding.


Remove the cBToken parameter and add a credentials binding with type "secret text".


Add the credentials for codeBeamer generating the secret as "Basic " + base64encode(username + ":" + password).

Example:

Assuming username is admin and password is secret

  1. Concatenate username and password -> admin:secret
  2. Base64 encode admin:secret using e.g. https://www.base64encode.org/ -> YWRtaW46c2VjcmV0
  3. Prepend Basic as prefix -> Basic YWRtaW46c2VjcmV0