From 7415ea494bd1c297f79f080983e4bc603a7c9307 Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:39:52 +0100 Subject: [PATCH 1/2] fix conflicts (#1930) --- .github/actions/package/action.yml | 2 +- .github/workflows/package-collect.yml | 2 +- .github/workflows/robot-test.yml | 4 ++-- .github/workflows/windows-agent.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/package/action.yml b/.github/actions/package/action.yml index f328ac6bab8..c281f65c9a7 100644 --- a/.github/actions/package/action.yml +++ b/.github/actions/package/action.yml @@ -118,7 +118,7 @@ runs: # Update if condition to true to get packages as artifacts - if: ${{ false }} name: Upload package artifacts - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: ${{ inputs.arch != '' && format('packages-{0}-{1}', inputs.distrib, inputs.arch) || format('packages-{0}', inputs.distrib) }} path: ./*.${{ inputs.package_extension}} diff --git a/.github/workflows/package-collect.yml b/.github/workflows/package-collect.yml index 35e2873b199..741d90fc857 100644 --- a/.github/workflows/package-collect.yml +++ b/.github/workflows/package-collect.yml @@ -223,7 +223,7 @@ jobs: # set condition to true if artifacts are needed - if: ${{ false }} name: Upload package artifacts - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: packages-${{ matrix.distrib }}-${{ matrix.arch }} path: ./*.${{ matrix.package_extension}} diff --git a/.github/workflows/robot-test.yml b/.github/workflows/robot-test.yml index eca3f40ac90..2c3640d07f5 100644 --- a/.github/workflows/robot-test.yml +++ b/.github/workflows/robot-test.yml @@ -183,7 +183,7 @@ jobs: - name: Upload Test Results if: ${{ failure() }} - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: reports-${{inputs.test_group_name}}-${{ steps.feature-path.outputs.feature_name_with_dash }} path: reports @@ -205,7 +205,7 @@ jobs: merge-multiple: true - name: Upload the regrouped artifact - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: reports-${{inputs.test_group_name}} path: reports/ diff --git a/.github/workflows/windows-agent.yml b/.github/workflows/windows-agent.yml index 67700206827..d852a53bac4 100644 --- a/.github/workflows/windows-agent.yml +++ b/.github/workflows/windows-agent.yml @@ -75,7 +75,7 @@ jobs: ! cancelled() && ! contains(needs.*.result, 'failure') && ! contains(needs.*.result, 'cancelled') - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: packages-centreon-monitoring-agent-windows path: centreon-monitoring-agent.zip From 129a09dbceafa2659f8ca441c570244582aa04fc Mon Sep 17 00:00:00 2001 From: May <110405507+mushroomempires@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:32:04 +0100 Subject: [PATCH 2/2] feat(ci): automate ticket creation on scheduled build failure (#1876) (#1921) * feat(ci): automate ticket creation on scheduled build failure (#1876) * incorporate action from web + 'backport' get-environment is_nightly management * add nightly creation ticket blocks in collect * remove useless github.base_ref reference * rewrite secret inheritance on package-collect * fix missing secrets * fix lint * add ticket creation code blocks on robot test delivery * remove out-of-scope triggers * fix --- .github/actions/create-jira-ticket/action.yml | 142 ++++++++++++++++++ .../nightly-ticket-template.json | 32 ++++ .github/workflows/centreon-collect.yml | 42 ++++++ .github/workflows/get-environment.yml | 27 ++++ .github/workflows/package-collect.yml | 31 +++- .github/workflows/robot-nightly.yml | 36 ++++- .github/workflows/robot-test.yml | 30 +++- 7 files changed, 330 insertions(+), 10 deletions(-) create mode 100644 .github/actions/create-jira-ticket/action.yml create mode 100644 .github/actions/create-jira-ticket/nightly-ticket-template.json diff --git a/.github/actions/create-jira-ticket/action.yml b/.github/actions/create-jira-ticket/action.yml new file mode 100644 index 00000000000..f05a1e81e1e --- /dev/null +++ b/.github/actions/create-jira-ticket/action.yml @@ -0,0 +1,142 @@ +name: Workflow incident tracking +description: Create Jira ticket on incident + +inputs: + jira_base_url: + required: true + description: jira base url + jira_user_email: + required: true + description: jira user email + jira_api_token: + required: true + description: jira api token + module_name: + required: true + description: module name + ticket_labels: + required: true + description: ticket labels, usually Pipeline + Nightly/Veracode + x + default: 'Pipeline' + +runs: + using: "composite" + steps: + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + + - name: Get ticket elements from context + id: get_context + run: | + # Safely set/unset IFS in order to parse the table of labels properly + [ -n "${IFS+set}" ] && saved_IFS=$IFS + IFS=', ' read -a ticket_labels <<< $(echo "${{ inputs.ticket_labels }}" | tr -d "[],'") + unset IFS + [ -n "${saved_IFS+set}" ] && { IFS=$saved_IFS; unset saved_IFS; } + + # Change context elements (summary, parent epic, etc.) that is checked depending on the ticket labels in the input + if [[ "${ticket_labels[@]}" =~ "Veracode" ]]; then + parent_epic_id=83818 + parent_epic_key="AT-268" + ticket_summary="PR-${{ github.event.pull_request.number }} incident on ${{ inputs.module_name }}" + + JSON_TEMPLATE_FILE="./.github/actions/create-jira-ticket/veracode-ticket-template.json" + sed -i \ + -e 's|@PULL_REQUEST_NUMBER@|${{ github.event.pull_request.number }}|g' \ + -e 's|@PULL_REQUEST_URL@|${{ github.event.pull_request.html_url }}|g' $JSON_TEMPLATE_FILE + elif [[ "${ticket_labels[@]}" =~ "Nightly" ]]; then + parent_epic_id=206242 + parent_epic_key="MON-151547" + ticket_summary="$(date '+%Y-%m-%d') ${{ inputs.module_name }}-${{ github.ref_name }} nightly build failure" + + JSON_TEMPLATE_FILE="./.github/actions/create-jira-ticket/nightly-ticket-template.json" + sed -i \ + -e 's|@MODULE_NAME@|${{ inputs.module_name }}|g' \ + -e "s|@DATE@|$(date '+%Y-%m-%d')|g" $JSON_TEMPLATE_FILE + else + echo "::error::Cannot find a valid labelling option for the ticket." + exit 1 + fi + + sed -i \ + -e 's|@GITHUB_BRANCH@|${{ github.base_ref || github.ref_name }}|g' \ + -e 's|@GITHUB_SERVER_URL@|${{ github.server_url }}|g' \ + -e 's|@GITHUB_REPOSITORY@|${{ github.repository }}|g' \ + -e 's|@GITHUB_RUN_ID@|${{ github.run_id }}|g' \ + -e 's|@GITHUB_RUN_ATTEMPT@|${{ github.run_attempt }}|g' $JSON_TEMPLATE_FILE + + echo "parent_epic_id=$parent_epic_id" >> $GITHUB_OUTPUT + echo "parent_epic_key=$parent_epic_key" >> $GITHUB_OUTPUT + echo "ticket_summary=$ticket_summary" >> $GITHUB_OUTPUT + echo "json_template_file=$JSON_TEMPLATE_FILE" >> $GITHUB_OUTPUT + + cat $JSON_TEMPLATE_FILE + cat $GITHUB_OUTPUT + shell: bash + env: + GH_TOKEN: ${{ github.token }} + + - name: Check if the ticket already exists + id: check_ticket + run: | + # Checking if an incident ticket already exists + response=$(curl \ + --write-out "%{http_code}" \ + --request POST \ + --url "${{ inputs.jira_base_url }}/rest/api/3/search" \ + --user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \ + --header "Accept:application/json" \ + --header "Content-Type:application/json" \ + --data '{ + "fields": ["summary"], + "jql": "project = MON AND parentEpic = ${{ steps.get_context.outputs.parent_epic_key }} AND issueType = Technical AND summary ~ \"${{ steps.get_context.outputs.ticket_summary }}\" AND component = \"${{ inputs.module_name }}\" AND resolution = unresolved ORDER BY key ASC", + "maxResults": 1 + }' + ) + echo "[DEBUG] $response" + if [[ $(echo "$response" | tr -d '\n' | tail -c 3) -ne 200 ]]; then + echo "::error:: Jira API request was not completed properly." + fi + check_if_ticket_exists=$(echo "$response" | head -c -4 | jq .issues[0].key) + if [[ "$check_if_ticket_exists" != "null" ]]; then + echo "abort_ticket_creation=true" >> $GITHUB_ENV + echo "::error::ticket found as $check_if_ticket_exists aborting ticket creation" + fi + shell: bash + + - name: Create Jira Issue + if: ${{ env.abort_ticket_creation != 'true' }} + run: | + # Creating a new incident ticket on Jira + DATA=$( cat <<-EOF + { + "fields": { + "summary": "${{ steps.get_context.outputs.ticket_summary }}", + "project": {"key": "MON"}, + "issuetype": {"id": "10209"}, + "parent": {"id": "${{ steps.get_context.outputs.parent_epic_id }}", "key": "${{ steps.get_context.outputs.parent_epic_key }}"}, + "labels": ${{ inputs.ticket_labels }}, + "components":[{"name": "${{ inputs.module_name }}"}], + "customfield_10902": {"id": "10524", "value": "DevSecOps"}, + "customfield_10005": 1.0, + "description": $(cat ${{ steps.get_context.outputs.json_template_file }}) + } + } + EOF + ) + + response=$(curl \ + --request POST \ + --url "${{ inputs.jira_base_url }}/rest/api/3/issue" \ + --user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \ + --header 'Accept: application/json' \ + --header 'Content-Type: application/json' \ + --data "$DATA") + echo $response + if [ $? -ne 0 ]; then + echo "::error::Failed to create ticket: $response" + exit 1 + fi + + ticket_key=$(echo "$response" | jq -r .key) + echo "::notice::Created ticket: $ticket_key" + shell: bash diff --git a/.github/actions/create-jira-ticket/nightly-ticket-template.json b/.github/actions/create-jira-ticket/nightly-ticket-template.json new file mode 100644 index 00000000000..aed95eed370 --- /dev/null +++ b/.github/actions/create-jira-ticket/nightly-ticket-template.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "type": "doc", + "content": [ + { + "type": "paragraph", + "content": [ + { + "type": "text", + "text": "This incident ticket relates to the @MODULE_NAME@ nightly on the @GITHUB_BRANCH@ branch which failed on @DATE@." + } + ] + }, + { + "type": "paragraph", + "content": [ + { + "type": "text", + "text": "Link to the failed nightly", + "marks": [ + { + "type": "link", + "attrs": { + "href": "@GITHUB_SERVER_URL@/@GITHUB_REPOSITORY@/actions/runs/@GITHUB_RUN_ID@/attempts/@GITHUB_RUN_ATTEMPT@" + } + } + ] + } + ] + } + ] +} diff --git a/.github/workflows/centreon-collect.yml b/.github/workflows/centreon-collect.yml index 780a9c2b39e..5a37065b161 100644 --- a/.github/workflows/centreon-collect.yml +++ b/.github/workflows/centreon-collect.yml @@ -1,4 +1,10 @@ name: Centreon collect +run-name: | + ${{ + (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.nightly_manual_trigger == 'true')) + && format('collect nightly {0}', github.ref_name) + || '' + }} concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -6,6 +12,14 @@ concurrency: on: workflow_dispatch: + inputs: + nightly_manual_trigger: + description: 'Set to true for nightly run' + required: true + default: false + type: boolean + schedule: + - cron: '30 0 * * 1-5' pull_request: paths: - agent/** @@ -61,6 +75,7 @@ jobs: uses: ./.github/workflows/get-environment.yml with: version_file: CMakeLists.txt + nightly_manual_trigger: ${{ inputs.nightly_manual_trigger }} unit-test: needs: [get-environment] @@ -103,6 +118,7 @@ jobs: release: ${{ needs.get-environment.outputs.release }} commit_hash: ${{ github.sha }} stability: ${{ needs.get-environment.outputs.stability }} + is_nightly: ${{ needs.get-environment.outputs.is_nightly }} secrets: inherit deliver-sources: @@ -156,6 +172,19 @@ jobs: release_type: ${{ needs.get-environment.outputs.release_type }} is_cloud: ${{ needs.get-environment.outputs.is_cloud }} + - name: Create Jira ticket if nightly build failure + if: | + needs.get-environment.outputs.is_nightly == 'true' && github.run_attempt == 1 && + failure() && + startsWith(github.ref_name, 'dev') + uses: ./.github/actions/create-jira-ticket + with: + jira_base_url: ${{ secrets.JIRA_BASE_URL }} + jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} + jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} + module_name: "centreon-collect" + ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]' + deliver-deb: if: ${{ contains(fromJson('["testing", "stable"]'), needs.get-environment.outputs.stability) }} needs: [get-environment, package] @@ -190,6 +219,19 @@ jobs: release_type: ${{ needs.get-environment.outputs.release_type }} is_cloud: ${{ needs.get-environment.outputs.is_cloud }} + - name: Create Jira ticket if nightly build failure + if: | + needs.get-environment.outputs.is_nightly == 'true' && github.run_attempt == 1 && + failure() && + startsWith(github.ref_name, 'dev') + uses: ./.github/actions/create-jira-ticket + with: + jira_base_url: ${{ secrets.JIRA_BASE_URL }} + jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} + jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} + module_name: "centreon-collect" + ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]' + promote: needs: [get-environment, deliver-rpm, deliver-deb] if: | diff --git a/.github/workflows/get-environment.yml b/.github/workflows/get-environment.yml index d88b4128337..158e1e8f5a6 100644 --- a/.github/workflows/get-environment.yml +++ b/.github/workflows/get-environment.yml @@ -5,6 +5,9 @@ on: required: false type: string default: CMakeLists.txt + nightly_manual_trigger: + required: false + type: boolean outputs: latest_major_version: description: "latest major version" @@ -33,6 +36,9 @@ on: is_targeting_feature_branch: description: "if it is a PR, check if targeting a feature branch" value: ${{ jobs.get-environment.outputs.is_targeting_feature_branch }} + is_nightly: + description: "if the current workflow run is considered a nightly" + value: ${{ jobs.get-environment.outputs.is_nightly }} img_version: description: "docker image version (vcpkg checksum)" value: ${{ jobs.get-environment.outputs.img_version }} @@ -56,6 +62,7 @@ jobs: target_stability: ${{ steps.get_stability.outputs.target_stability }} release_type: ${{ steps.get_release_type.outputs.release_type }} is_targeting_feature_branch: ${{ steps.get_stability.outputs.is_targeting_feature_branch }} + is_nightly: ${{ steps.get_nightly_status.outputs.is_nightly }} img_version: ${{ steps.get_docker_images_version.outputs.img_version }} test_img_version: ${{ steps.get_docker_images_version.outputs.test_img_version }} gorgone_docker_version: ${{ steps.get_docker_images_version.outputs.gorgone_docker_version }} @@ -226,6 +233,25 @@ jobs: return false; + - name: Detect nightly status + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + id: get_nightly_status + env: + NIGHTLY_MANUAL_TRIGGER: ${{ inputs.nightly_manual_trigger }} + with: + script: | + const getNightlyInput = () => { + const nightly_manual_trigger = process.env.NIGHTLY_MANUAL_TRIGGER; + console.log(nightly_manual_trigger); + if (typeof nightly_manual_trigger === 'undefined' || nightly_manual_trigger === '') { + return 'false'; + } else if (context.eventName === 'schedule' || context.eventName === 'workflow_dispatch' && nightly_manual_trigger === 'true' ) { + return 'true'; + } + return 'false'; + }; + core.setOutput('is_nightly', getNightlyInput()); + - name: Get docker images version id: get_docker_images_version run: | @@ -254,6 +280,7 @@ jobs: ['stability', '${{ steps.get_stability.outputs.stability }}'], ['release_type', '${{ steps.get_release_type.outputs.release_type || 'not defined because this is not a release' }}'], ['is_targeting_feature_branch', '${{ steps.get_stability.outputs.is_targeting_feature_branch }}'], + ['is_nightly', '${{ steps.get_nightly_status.outputs.is_nightly }}'], ['img_version', '${{ steps.get_docker_images_version.outputs.img_version }}'], ['test_img_version', '${{ steps.get_docker_images_version.outputs.test_img_version }}'], ['gorgone_docker_version', '${{ steps.get_docker_images_version.outputs.gorgone_docker_version }}'], diff --git a/.github/workflows/package-collect.yml b/.github/workflows/package-collect.yml index 741d90fc857..4776156e7b3 100644 --- a/.github/workflows/package-collect.yml +++ b/.github/workflows/package-collect.yml @@ -21,7 +21,9 @@ on: stability: required: true type: string - + is_nightly: + required: false + type: string jobs: package: strategy: @@ -70,14 +72,14 @@ jobs: SCCACHE_PATH: "/usr/bin/sccache" SCCACHE_BUCKET: "centreon-github-sccache" SCCACHE_REGION: "eu-west-1" - AWS_ACCESS_KEY_ID: ${{ secrets.COLLECT_S3_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }} + AWS_ACCESS_KEY_ID: ${{ secrets.collect_s3_access_key }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.collect_s3_secret_key }} container: image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:${{ inputs.img_version }} credentials: - username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }} - password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }} + username: ${{ secrets.registry_username }} + password: ${{ secrets.registry_password }} name: package ${{ matrix.distrib }} ${{ matrix.arch }} @@ -226,5 +228,22 @@ jobs: uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: packages-${{ matrix.distrib }}-${{ matrix.arch }} - path: ./*.${{ matrix.package_extension}} + path: ./*.${{ matrix.package_extension }} retention-days: 1 + + create-jira-nightly-ticket: + needs: [package] + runs-on: ubuntu-24.04 + if: | + inputs.is_nightly == 'true' && github.run_attempt == 1 && + (failure() || cancelled()) && + startsWith(github.ref_name, 'dev') + steps: + - name: Create Jira ticket if nightly build failure + uses: ./.github/actions/create-jira-ticket + with: + jira_base_url: ${{ secrets.jira_base_url }} + jira_user_email: ${{ secrets.jira_user_email }} + jira_api_token: ${{ secrets.jira_api_token }} + module_name: "centreon-collect" + ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "package"]' diff --git a/.github/workflows/robot-nightly.yml b/.github/workflows/robot-nightly.yml index 1e6c18717b1..0652ff3399b 100644 --- a/.github/workflows/robot-nightly.yml +++ b/.github/workflows/robot-nightly.yml @@ -57,6 +57,7 @@ jobs: img_version: ${{ needs.get-environment.outputs.img_version }} release: ${{ needs.get-environment.outputs.release }} commit_hash: ${{ github.sha }} + is_nightly: ${{ needs.get-environment.outputs.is_nightly }} secrets: inherit robot-test: @@ -119,10 +120,10 @@ jobs: image_test: ${{ matrix.image }}:${{ needs.get-environment.outputs.test_img_version }} image_version: ${{ needs.get-environment.outputs.img_version }} package_cache_key: ${{ github.run_id }}-${{ github.sha }}-${{ matrix.package_extension }}-centreon-collect-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }} - package_cache_path: ./*.${{ matrix.package_extension}} + package_cache_path: ./*.${{ matrix.package_extension }} database_type: ${{ matrix.database_type }} - tests_params: ${{matrix.tests_params}} - test_group_name: ${{matrix.test_group_name}} + tests_params: ${{ matrix.tests_params }} + test_group_name: ${{ matrix.test_group_name }} secrets: registry_username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }} registry_password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }} @@ -130,6 +131,9 @@ jobs: collect_s3_secret_key: ${{ secrets.COLLECT_S3_SECRET_KEY }} xray_client_id: ${{ secrets.XRAY_CLIENT_ID }} xray_client_secret: ${{ secrets.XRAY_CLIENT_SECRET }} + jira_base_url: ${{ secrets.JIRA_BASE_URL }} + jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} + jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} deliver-rpm: if: ${{ contains(fromJson('["unstable"]'), needs.get-environment.outputs.stability) }} @@ -156,6 +160,19 @@ jobs: release_type: ${{ needs.get-environment.outputs.release_type }} is_cloud: ${{ needs.get-environment.outputs.is_cloud }} + - name: Create Jira ticket if nightly build failure + if: | + needs.get-environment.outputs.is_nightly == 'true' && github.run_attempt == 1 && + failure() && + startsWith(github.ref_name, 'dev') + uses: ./.github/actions/create-jira-ticket + with: + jira_base_url: ${{ secrets.JIRA_BASE_URL }} + jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} + jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} + module_name: "centreon-collect" + ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]' + deliver-deb: if: ${{ contains(fromJson('["unstable"]'), needs.get-environment.outputs.stability) }} needs: [robot-test, get-environment] @@ -188,3 +205,16 @@ jobs: stability: ${{ needs.get-environment.outputs.stability }} release_type: ${{ needs.get-environment.outputs.release_type }} is_cloud: ${{ needs.get-environment.outputs.is_cloud }} + + - name: Create Jira ticket if nightly build failure + if: | + needs.get-environment.outputs.is_nightly == 'true' && github.run_attempt == 1 && + failure() && + startsWith(github.ref_name, 'dev') + uses: ./.github/actions/create-jira-ticket + with: + jira_base_url: ${{ secrets.JIRA_BASE_URL }} + jira_user_email: ${{ secrets.XRAY_JIRA_USER_EMAIL }} + jira_api_token: ${{ secrets.XRAY_JIRA_TOKEN }} + module_name: "centreon-collect" + ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]' diff --git a/.github/workflows/robot-test.yml b/.github/workflows/robot-test.yml index 2c3640d07f5..ec9eec6537d 100644 --- a/.github/workflows/robot-test.yml +++ b/.github/workflows/robot-test.yml @@ -31,6 +31,9 @@ on: test_group_name: required: true type: string + is_nightly: + required: false + type: string secrets: registry_username: required: true @@ -44,7 +47,12 @@ on: required: true xray_client_secret: required: true - + jira_base_url: + required: true + jira_user_email: + required: true + jira_api_token: + required: true jobs: test-image-to-cache: runs-on: ${{ contains(inputs.image, 'arm') && fromJson('["self-hosted", "collect-arm64"]') || 'ubuntu-24.04' }} @@ -266,3 +274,23 @@ jobs: gh_access_token: ${{ secrets.GITHUB_TOKEN }} report_path: reports show_passed_tests: false + + create-jira-nightly-ticket: + needs: [robot-test-list, robot-test, robot-test-report] + runs-on: ubuntu-24.04 + if: | + inputs.is_nightly == 'true' && github.run_attempt == 1 && + (failure() || cancelled()) && + startsWith(github.ref_name, 'dev') + steps: + - name: Checkout sources + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + + - name: Create Jira ticket if nightly build failure + uses: ./.github/actions/create-jira-ticket + with: + jira_base_url: ${{ secrets.jira_base_url }} + jira_user_email: ${{ secrets.jira_user_email }} + jira_api_token: ${{ secrets.jira_api_token }} + module_name: "centreon-collect" + ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "robot-test"]'