Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For the Travis CI the important change we must do is in the YAML file that will configure Travis CI pipeline, we use the following configuration to achieve that:
.travis.yml

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 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.

...

In this case, since Jenkins was configured to report results back to Xray, a new Test Execution would be created in Jira/Xray.

Image AddedImage Removed

Associated with the Test Plan that we have passed along:

...