In this very simple scenario, we'll implement a rule, triggered manually, that will trigger a TravisCI project/job. The action will be available from the "Automation" panel, in all issues of the selected project.
We're assuming that:
In TravisCI, we need to generate an API authentication token for some user, which can be done from the My Account settings page.
We have defined the following configuration in our source code that will be used in TravisCI configuration of the pipeline:
sudo: false language: java jdk: - openjdk8 cache: directories: - "$HOME/.cache" jobs: include: - stage: test and report to Xray script: - | echo "building repo..." mvn clean compile test --file pom.xml 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/v2/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/v2/import/execution/junit?projectKey=$PROJECTKEY" echo "done" |
For the configuration of the YAML file we used the TravisCI tutorial documentation.
As you can see we are pushing results back to Xray with the last curl command:
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/v2/import/execution/junit?projectKey=$PROJECTKEY" |
On this command we are passing the project key in order to report back to a specific Project in the Xray side, we will further ahead show how it is populated.
Once we have the authentication token we followed the TravisCI API documentation to configure the following steps on the Jira side.
On the Jira side we will use the Automation capabilities that it provides out of the box, so within the project you want to use automation go to project settings and:
2. define an action (i.e. the "Then") as "Send web request" and configure it as follows
After publishing the rule, you can go to the screen of an issue and trigger the TravisCI project/job.
In this case, since TravisCI was configured to report results back to Xray, 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 TravisCI project/job. The action will be available from the "Automation" panel, for all Test Plan issues of the selected project.
We're assuming that:
In TravisCI, we need to generate an API authentication token for some user, which can be done from the My Account settings page.
Once we have the authentication token we followed the TravisCI API documentation to configure the following steps on the Jira side.
For the TravisCI the important change we must do is in the YAML file that will configure TravisCI pipeline, we use the following configuration to achieve that:
sudo: false language: java jdk: - openjdk8 cache: directories: - "$HOME/.cache" jobs: include: - stage: test and report to Xray script: - | echo "building repo..." mvn clean compile test --file pom.xml 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/v2/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/v2/import/execution/junit?projectKey=$PROJECTKEY&testPlanKey=$TESTPLAN" echo "done" |
For more details about this configuration please check the TravisCI tutorial documentation.
As you can see we are pushing results back to Xray with the last curl command:
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/v2/import/execution/junit?projectKey=$PROJECTKEY&testPlanKey=$TESTPLAN" |
On this command we are passing the project key in order to report back to a specific Project in the Xray side, we will further ahead show how it is populated.
Once we have the authentication token we followed the TravisCI API documentation to configure the following steps on the Jira side.
On the Jira side we will use the Automation capabilities that it provides out of the box, so within the project you want to use automation go to the automation entry in the project settings and:
2. define a condition, in our case we will define that only Test Plan issue types will be allowed to trigger this pipeline; this could also be defined on the previous step
3. define an action (i.e. the "Then") as "Send web request" and configure it as follows
After publishing the rule, you can go to the screen of a Test Plan issue and trigger the TravisCI project/job.
In this case, since TravisCI was configured to report results back to Xray, a new Test Execution would be created in Jira/Xray.
Associated with the Test Plan that we have passed along: