In this very simple scenario, we'll implement a rule, triggered manually, that will trigger a Bitbucket pipeline build. The action will be available from the "Automation" panel, in all issues of the selected project.
We're assuming that:
In Bitbucket we need to configure the pipeline as usual; no special configuration is needed. Some variables can be used and defined at multiple layers.
# Use Maven 3.5 and JDK8 image: maven:3.5-jdk-8 pipelines: default: - step: caches: - maven script: - | echo "building my amazing repo..." mvn test export token=$(curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"$client_id\",\"client_secret\": \"$client_secret\" }" https://xray.cloud.xpand-it.com/api/v1/authenticate| tr -d '"') echo $token curl -H "Content-Type: text/xml" -H "Authorization: Bearer $token" --data @target/surefire-reports/TEST-com.xpand.java.CalcTest.xml "https://xray.cloud.xpand-it.com/api/v1/import/execution/junit?projectKey=CALC&testPlanKey=$testplan" echo "done |
2. define an action (i.e. the "Then") as "Send web request" and configure it as follows
{ "target": { "ref_type": "branch", "type": "pipeline_ref_target", "ref_name": "master" } } |
the Webhook HTTP POST body content, defined in the "Custom data" field, will be used to identify the target branch and also a variable containing the Test Plan issue key that will be accessible to the pipeline build
{ "target": { "ref_type": "branch", "type": "pipeline_ref_target", "ref_name": "master" } , "variables": [ { "key": "testplan", "value": "{{issue.key}}" } ] } |
After publishing the rule, you can go to the screen of an issue and trigger the Bitbucket pipeline build.
In this case, a new Test Execution would be created in Jira/Xray.
In this simple scenario, we'll implement a rule, triggered manually, that will trigger a Bitbucket pipeline build. The action will be available from the "Automation" panel, for all Test Plan issues of the selected project.
We're assuming that:
In Bitbucket pipeline definition we will make use of a variable named "testplan" (referenced by $testplan). This variable does not need to be defined explicitly as such in Bitbucket; Bitbucket will pass to the pipeline all "variables" identified in the REST API request, if so, whenever triggering the pipeline.
# Use Maven 3.5 and JDK8 image: maven:3.5-jdk-8 pipelines: default: - step: caches: - maven script: - | echo "building my amazing repo..." mvn test export token=$(curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"$client_id\",\"client_secret\": \"$client_secret\" }" https://xray.cloud.xpand-it.com/api/v1/authenticate| tr -d '"') echo $token curl -H "Content-Type: text/xml" -H "Authorization: Bearer $token" --data @target/surefire-reports/TEST-com.xpand.java.CalcTest.xml "https://xray.cloud.xpand-it.com/api/v1/import/execution/junit?projectKey=CALC&testPlanKey=$testplan" echo "done |
2. define the condition so that this rule can only be executed from Test Plan issue; we could also define this on the previous step
3. define an action (i.e. the "Then") as "Send web request" and configure it as follows
the Webhook HTTP POST body content, defined in the "Custom data" field, will be used to identify the target branch and also a variable containing the Test Plan issue key that will be accessible to the pipeline build
{ "target": { "ref_type": "branch", "type": "pipeline_ref_target", "ref_name": "master" } , "variables": [ { "key": "testplan", "value": "{{issue.key}}" } ] } |
After publishing the rule, you can go to the screen of an issue and trigger the Bitbucket pipeline.
In this case, a new Test Execution would be created and linked back to the source Test Plan where the automation was triggered from