diff --git a/generator-nr-maven-build/generators/app/templates/ci.yaml b/generator-nr-maven-build/generators/app/templates/ci.yaml index edaca85..8fa0c45 100644 --- a/generator-nr-maven-build/generators/app/templates/ci.yaml +++ b/generator-nr-maven-build/generators/app/templates/ci.yaml @@ -1,4 +1,5 @@ name: Java CI + on: pull_request: branches: [main] @@ -30,6 +31,7 @@ jobs: outputs: project_version: ${{ steps.set-build-output-parameters.outputs.project_version }} intention_id: ${{ steps.set-intention-id.outputs.intention_id }} + branch: ${{ steps.set-branch-ci.outputs.branch }} steps: - uses: actions/checkout@v4 @@ -43,6 +45,13 @@ jobs: server-username: ARTIFACTORY_USERNAME server-password: ARTIFACTORY_PASSWORD + # Get branch for manual runs + - name: Get branch + id: set-branch-ci + if: ${{ startsWith(github.ref, 'refs/heads/') }} + run: | + echo "branch=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" + - name: Set build output parameters id: set-build-output-parameters run: | @@ -163,10 +172,17 @@ jobs: url: https://cd.io.nrs.gov.bc.ca PROJECT_VERSION: ${{ needs.publish.outputs.project_version }} INTENTION_ID: ${{ needs.publish.outputs.intention_id }} + BRANCH: ${{ needs.publish.outputs.branch }} run: | - curl --data-urlencode "token=${{ secrets.JENKINS_TOKEN }}" --data-urlencode "githubToken=${{ secrets.GITHUB_TOKEN }}" \ - --data-urlencode "artifactoryBuildNumber=${{ github.run_number }}" --data-urlencode "cdVersion=${{ env.PROJECT_VERSION }}" \ - --data-urlencode "intentionId=${{ env.INTENTION_ID }}" -H "Connection: close" ${{ env.url }}/${{ env.job }} + curl \ + --data-urlencode "token=${{ secrets.JENKINS_TOKEN }}" \ + --data-urlencode "githubToken=${{ secrets.GITHUB_TOKEN }}" \ + --data-urlencode "artifactoryBuildNumber=${{ github.run_number }}" \ + --data-urlencode "cdVersion=${{ env.PROJECT_VERSION }}" \ + --data-urlencode "gitBranch=${{ env.BRANCH }}" \ + --data-urlencode "intentionId=${{ env.INTENTION_ID }}" \ + -H "Connection: close" \ + ${{ env.url }}/${{ env.job }} # The automatically generated GitHub token will expire when the workflow ends. We need to wait so the job has time to clone the repo. - name: Sleep for 30 seconds run: sleep 30s