We need to create a personal access token so that we can use GitHub API later on. That can be done from within the user's profile.
The token must have "workflow" scope enabled.
Then, in your GitHub repository containing the project's code and tests, create a workflow under .github/workflows
.
The workflow will be triggered upon a "workflow dispatch" event, which is usually manually triggered. However, this event can also be triggered using GitHub's API.
In the following example the workflow will receive the Test Plan issue key as an input parameter. It will then run the build, including the automated tests, and in the end it will report the results back to Xray using the open-source GitHub action xray-action.
name: CI (Jira cloud example with GH action, report results to Test Plan - demo) on: workflow_dispatch: inputs: test_plan_key: description: 'Test Plan issue key' required: false default: '' jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Set up Java uses: actions/setup-java@v1 with: java-version: '1.8' - name: Cache Maven packages uses: actions/cache@v2 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - name: Build with Maven run: mvn clean compile test --file pom.xml - name: Submit results to Xray uses: mikepenz/xray-action@v2.4.5 with: username: ${{ secrets.client_id }} password: ${{ secrets.client_secret }} xrayCloud: true testFormat: "junit" testPaths: "**/surefire-reports/*.xml" projectKey: "CALC" testPlanKey: ${{ github.event.inputs.test_plan_key }} |
2. define the condition so that this rule can only be executed from Test Plan issue; this can also be done on the previous step
3. define an action (i.e. the "Then") as "Send web request" and configure it as follows
the HTTP POST body content, defined in the "Custom data" field, will be used to identify the original Test Plan issue key and the branch of the code
{ "ref":"main", "inputs": { "test_plan_key": "{{issue.key}}" } } |
After publishing the rule, you can go to the screen of an issue and trigger a workflow run in GitHub.
In this case, since the workflow was configured to report results back to Xray, a new Test Execution would be created and linked back to the source Test Plan where the automation was triggered from.