mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-09-25 10:48:40 +02:00
enh(nightly-ci): split created nightly ticket by type of failure (#5705)
This commit is contained in:
parent
0f8af4dd53
commit
27e49958f8
370
.github/actions/create-jira-ticket/action.yml
vendored
370
.github/actions/create-jira-ticket/action.yml
vendored
@ -14,295 +14,167 @@ inputs:
|
|||||||
module_name:
|
module_name:
|
||||||
required: true
|
required: true
|
||||||
description: module name
|
description: module name
|
||||||
ticket_labels:
|
ticket_reason_for_creation:
|
||||||
required: true
|
required: true
|
||||||
description: ticket labels, usually Pipeline + Nightly/Veracode + x
|
description: reason for ticket creation
|
||||||
default: 'Pipeline'
|
default: "Nightly"
|
||||||
ticket_squad:
|
|
||||||
required: true
|
|
||||||
description: id of the squad to assign the ticket to
|
|
||||||
default: 'DevSecOps'
|
|
||||||
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Install DayJS
|
||||||
|
run: npm install dayjs
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Get ticket elements from context
|
- name: Get ticket elements from context
|
||||||
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
id: get_context
|
id: get_context
|
||||||
run: |
|
with:
|
||||||
# Safely set/unset IFS in order to properly parse the table of labels
|
script: |
|
||||||
[ -n "${IFS+set}" ] && saved_IFS=$IFS
|
const fs = require('fs');
|
||||||
IFS=', ' read -a ticket_labels <<< $(echo "${{ inputs.ticket_labels }}" | tr -d "[],'")
|
const { execSync } = require('child_process');
|
||||||
unset IFS
|
const dayjs = require('dayjs');
|
||||||
[ -n "${saved_IFS+set}" ] && { IFS=$saved_IFS; unset saved_IFS; }
|
const isoWeek = require('dayjs/plugin/isoWeek');
|
||||||
|
dayjs.extend(isoWeek);
|
||||||
|
|
||||||
# Change the context elements (summary, parent epic, etc.) that are checked depending on these ticket labels
|
const parent_epic_id = 206242
|
||||||
if [[ "${ticket_labels[@]}" =~ "Nightly" ]]; then
|
const parent_epic_key = "MON-151547"
|
||||||
parent_epic_id=206242
|
const JSON_TEMPLATE_FILE = "./.github/actions/create-jira-ticket/nightly-ticket-template.json";
|
||||||
parent_epic_key="MON-151547"
|
const date = dayjs().format('YYYY-MM-DD');
|
||||||
ticket_summary="$(date '+%Y-%m-%d') ${{ inputs.module_name }}-${{ github.ref_name }} nightly build failure"
|
const path = './ticket-payload.json';
|
||||||
|
let contents, data, ticket_summary, ticket_squad_id, ticket_board_id, squad_name, project_name, ticket_labels, current_sprint, ticket_data, ticket_key;
|
||||||
|
|
||||||
JSON_TEMPLATE_FILE="./.github/actions/create-jira-ticket/nightly-ticket-template.json"
|
let failed_jobs = JSON.parse(execSync(
|
||||||
sed -i \
|
`gh run view ${{ github.run_id }} --json jobs -q '[.jobs[] | select(.conclusion == "failure") | .name | split(" ")[0] ] | unique'`,
|
||||||
-e 's|@MODULE_NAME@|${{ inputs.module_name }}|g' \
|
{ encoding: 'utf8' }
|
||||||
-e "s|@DATE@|$(date '+%Y-%m-%d')|g" $JSON_TEMPLATE_FILE
|
));
|
||||||
|
console.log(failed_jobs);
|
||||||
|
|
||||||
else
|
for (const failed_job of failed_jobs) {
|
||||||
echo "::error::Cannot find a valid labelling option for the ticket."
|
ticket_labels = ["Pipeline", "${{ inputs.ticket_reason_for_creation }}" ]
|
||||||
exit 1
|
console.log(`Failed job: ${failed_job}`);
|
||||||
fi
|
if (ticket_labels.includes("Nightly")) {
|
||||||
|
ticket_summary = `${date} ${{ inputs.module_name }}-${{ github.base_ref || github.ref_name }} nightly build failure on ${failed_job}`
|
||||||
|
|
||||||
case "${{ inputs.ticket_squad }}" in
|
data = fs.readFileSync(JSON_TEMPLATE_FILE, { encoding: 'utf8' });
|
||||||
"DevSecOps")
|
data = data.replace(/@MODULE_NAME@/g, '${{ inputs.module_name }}');
|
||||||
ticket_squad_id=10524
|
data = data.replace(/@DATE@/g, date);
|
||||||
ticket_board_id=184
|
|
||||||
squad_name="DEVSECOPS"
|
|
||||||
project_name="MON"
|
|
||||||
;;
|
|
||||||
"Connectors")
|
|
||||||
ticket_squad_id=10504
|
|
||||||
ticket_board_id=222
|
|
||||||
squad_name="CONNECTORS"
|
|
||||||
project_name="CTOR"
|
|
||||||
*)
|
|
||||||
echo "::error::Cannot find a valid squad for value ${{ inputs.ticket_squad }}."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "Ticket will be assigned to the $squad_name team."
|
data = data.replace(/@GITHUB_BRANCH@/g, '${{ github.base_ref || github.ref_name }}');
|
||||||
|
data = data.replace(/@GITHUB_SERVER_URL@/g, '${{ github.server_url }}');
|
||||||
|
data = data.replace(/@FAILED_JOB@/g, failed_job);
|
||||||
|
data = data.replace(/@GITHUB_REPOSITORY@/g, '${{ github.repository }}');
|
||||||
|
data = data.replace(/@GITHUB_RUN_ID@/g, '${{ github.run_id }}');
|
||||||
|
data = data.replace(/@GITHUB_RUN_ATTEMPT@/g, '${{ github.run_attempt }}');
|
||||||
|
} else {
|
||||||
|
throw new Error(`❌ Could not find any labelling option for the ticket.`);
|
||||||
|
}
|
||||||
|
|
||||||
current_sprint=$(curl --request GET \
|
console.log(data);
|
||||||
--url ${{ inputs.jira_base_url }}/rest/agile/1.0/board/$ticket_board_id/sprint?state=active \
|
|
||||||
|
if (["get-environment", "get-plugins", "package", "deliver-packages"].includes(failed_job)) {
|
||||||
|
ticket_squad_id = 10524
|
||||||
|
ticket_board_id = 184
|
||||||
|
squad_name = "DEVSECOPS"
|
||||||
|
project_name = "MON"
|
||||||
|
} else if (["unit-tests", "fatpacker", "test-plugins"].includes(failed_job)) {
|
||||||
|
ticket_squad_id = 10504
|
||||||
|
ticket_board_id = 222
|
||||||
|
squad_name = "COLLECT"
|
||||||
|
project_name = "CTOR"
|
||||||
|
} else {
|
||||||
|
core.setFailed(`Not finding any squad association with job ${failed_job}.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Ticket summary: ${ticket_summary}`);
|
||||||
|
console.log(`Ticket will be attributed to the ${squad_name} team. (Squad ID ${ticket_squad_id}, Board ID ${ticket_board_id})`)
|
||||||
|
|
||||||
|
current_sprint = execSync(
|
||||||
|
`curl --request GET \
|
||||||
|
--url ${{ inputs.jira_base_url }}/rest/agile/1.0/board/${ticket_board_id}/sprint?state=active \
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
||||||
--header "Accept: application/json" | jq --arg squad_name "$squad_name" '.values[] | select(.name | test($squad_name; "i")) | .id')
|
--header "Accept: application/json" | jq --arg squad_name "$squad_name" '.values[] | select(.name | test($squad_name; "i")) | .id'
|
||||||
|
`,
|
||||||
|
{ encoding: 'utf8' }
|
||||||
|
);
|
||||||
|
|
||||||
echo "[DEBUG] current_sprint: $current_sprint"
|
console.log(`Current sprint: ${current_sprint}`);
|
||||||
|
|
||||||
# General updates on all template files
|
// Creating a new incident ticket on Jira
|
||||||
sed -i \
|
data = JSON.parse(data);
|
||||||
-e 's|@GITHUB_BRANCH@|${{ github.base_ref || github.ref_name }}|g' \
|
ticket_data =
|
||||||
-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 "ticket_board_id=$ticket_board_id" >> $GITHUB_OUTPUT
|
|
||||||
echo "ticket_squad_id=$ticket_squad_id" >> $GITHUB_OUTPUT
|
|
||||||
echo "project_name=$project_name" >> $GITHUB_OUTPUT
|
|
||||||
echo "current_sprint=$current_sprint" >> $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 = ${{ steps.get_context.outputs.project_name }} 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
|
|
||||||
|
|
||||||
ticket_key=$(echo "$response" | head -c -4 | jq .issues[0].key | xargs)
|
|
||||||
if [[ "$ticket_key" != "null" ]]; then
|
|
||||||
echo "abort_ticket_creation=true" >> $GITHUB_ENV
|
|
||||||
echo "ticket_key=$ticket_key" >> $GITHUB_ENV
|
|
||||||
echo "::notice::ticket found as $ticket_key aborting ticket creation"
|
|
||||||
fi
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Update existing nightly Jira ticket
|
|
||||||
if: |
|
|
||||||
env.abort_ticket_creation == 'true' &&
|
|
||||||
contains(steps.get_context.outputs.parent_epic_key, 'MON-151547')
|
|
||||||
run: |
|
|
||||||
# Adding failed job labels for already existing ticket
|
|
||||||
[ -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; }
|
|
||||||
|
|
||||||
for label in ${ticket_labels[@]}; do
|
|
||||||
response=$(curl \
|
|
||||||
--request PUT \
|
|
||||||
--url "${{ inputs.jira_base_url }}/rest/api/3/issue/${{ env.ticket_key }}" \
|
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
|
||||||
--header 'Accept: application/json' \
|
|
||||||
--header 'Content-Type: application/json' \
|
|
||||||
--data "{ \"update\": { \"labels\": [ { \"add\": \"$label\" } ] } }"
|
|
||||||
)
|
|
||||||
done
|
|
||||||
|
|
||||||
ticket_description=$(curl --request GET \
|
|
||||||
--url "${{ inputs.jira_base_url }}/rest/api/3/issue/${{ env.ticket_key }}" \
|
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
|
||||||
--header "Accept: application/json" | jq '.fields.description')
|
|
||||||
|
|
||||||
mapfile -t jobs_failed < <(gh run view ${{ github.run_id }} --json jobs -q '.jobs[] | select(.conclusion == "failure") | .name')
|
|
||||||
echo "[DEBUG] - jobs failed for component ${FAILED_COMPONENTS[index]}: $jobs_failed"
|
|
||||||
|
|
||||||
new_list_of_failed_jobs=$(for job in "${jobs_failed[@]}"; do
|
|
||||||
cat <<EOF
|
|
||||||
{
|
|
||||||
"type": "listItem",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "paragraph",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"text": "$job"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
done | jq -s '.'
|
|
||||||
)
|
|
||||||
|
|
||||||
updated_ticket_description=$(echo "$ticket_description" | jq --argjson new_list_of_failed_jobs "$new_list_of_failed_jobs" '
|
|
||||||
(.content[] | select(.type == "bulletList") | .content) = $new_list_of_failed_jobs
|
|
||||||
')
|
|
||||||
|
|
||||||
echo "[DEBUG] - updated_ticket_description = $updated_ticket_description"
|
|
||||||
|
|
||||||
curl --request PUT \
|
|
||||||
--url "${{ inputs.jira_base_url }}/rest/api/3/issue/${{ env.ticket_key }}" \
|
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
|
||||||
--header "Accept: application/json" \
|
|
||||||
--header "Content-Type: application/json" \
|
|
||||||
--data "{
|
|
||||||
\"fields\": {
|
|
||||||
\"description\": $updated_ticket_description
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Create Jira Issue
|
|
||||||
if: ${{ env.abort_ticket_creation != 'true' }}
|
|
||||||
run: |
|
|
||||||
# Get the name of the current job and list it
|
|
||||||
failed_job_name=$(gh run view ${{ github.run_id }} --json jobs | jq -r --arg job_name "${{ github.job }}" '.jobs[] | select(.name == $job_name) | .name')
|
|
||||||
|
|
||||||
CONTENT_TO_ADD_TO_TEMPLATE_FILE=$(jq -n --arg job "$failed_job_name" '{
|
|
||||||
"type": "bulletList",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "listItem",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "paragraph",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"text": $job
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}')
|
|
||||||
|
|
||||||
echo "[DEBUG] - CONTENT_TO_ADD_TO_TEMPLATE_FILE: $CONTENT_TO_ADD_TO_TEMPLATE_FILE"
|
|
||||||
|
|
||||||
TEMPLATE_FILE=$(cat ${{ steps.get_context.outputs.json_template_file }})
|
|
||||||
UPDATED_TEMPLATE_FILE=$(jq --argjson NEW_CONTENT "$CONTENT_TO_ADD_TO_TEMPLATE_FILE" '.content += [$NEW_CONTENT]' <<< "$TEMPLATE_FILE")
|
|
||||||
|
|
||||||
# Creating a new incident ticket on Jira
|
|
||||||
DATA=$( cat <<-EOF
|
|
||||||
{
|
{
|
||||||
"fields": {
|
"fields": {
|
||||||
"summary": "${{ steps.get_context.outputs.ticket_summary }}",
|
"summary": ticket_summary,
|
||||||
"project": {"key": "${{ steps.get_context.outputs.project_name }}"},
|
"project": {"key": `${project_name}`},
|
||||||
"issuetype": {"id": "10209"},
|
"issuetype": {"id": "10209"},
|
||||||
"parent": {"id": "${{ steps.get_context.outputs.parent_epic_id }}", "key": "${{ steps.get_context.outputs.parent_epic_key }}"},
|
"parent": {"id": `${parent_epic_id}`, "key": `${parent_epic_key}`},
|
||||||
"labels": ${{ inputs.ticket_labels }},
|
"labels": ticket_labels,
|
||||||
"components":[{"name": "${{ inputs.module_name }}"}],
|
"components": [{"name": "${{ inputs.module_name }}"}],
|
||||||
"customfield_10902": {"id": "${{ steps.get_context.outputs.ticket_squad_id }}", "value": "${{ inputs.ticket_squad }}"},
|
"customfield_10902": {"id": `${ticket_squad_id}`, "value": `${squad_name}`},
|
||||||
"description": $UPDATED_TEMPLATE_FILE
|
"description": data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
if [[ ${{ steps.get_context.outputs.current_sprint }} != "null" ]]; then
|
if (current_sprint !== null) {
|
||||||
DATA=$(echo "$DATA" | jq '.fields.customfield_10007 = ${{ steps.get_context.outputs.current_sprint }}')
|
ticket_data.fields.customfield_10007 = parseInt(current_sprint, 10);
|
||||||
fi
|
}
|
||||||
echo "[DEBUG] - DATA: $DATA"
|
|
||||||
|
|
||||||
response=$(curl \
|
fs.writeFileSync(path, JSON.stringify(ticket_data));
|
||||||
--request POST \
|
contents = fs.readFileSync('./ticket-payload.json', 'utf8');
|
||||||
|
console.log("Ticket Payload:\n", contents);
|
||||||
|
let response = execSync(
|
||||||
|
`curl --request POST \
|
||||||
--url "${{ inputs.jira_base_url }}/rest/api/3/issue" \
|
--url "${{ inputs.jira_base_url }}/rest/api/3/issue" \
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
||||||
--header 'Accept: application/json' \
|
--header 'Accept: application/json' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data "$DATA")
|
--data @${path}
|
||||||
|
`,
|
||||||
|
{ encoding: 'utf8' }
|
||||||
|
);
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
console.log(`Response on ticket creation: ${response}`);
|
||||||
echo "::error::Failed to create ticket: $response"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $response
|
ticket_key = JSON.parse(response).key;
|
||||||
|
core.notice(`Created ticket: ${ticket_key}`);
|
||||||
|
|
||||||
ticket_key=$(echo "$response" | jq -r .key)
|
// Update priority on newly created ticket since you cannot create a ticket with another priority than medium
|
||||||
echo "::notice::Created ticket: $ticket_key"
|
response = execSync(
|
||||||
|
`curl --request PUT \
|
||||||
# Update priority on newly created ticket since you cannot create a ticket with another priority than medium
|
--url "${{ inputs.jira_base_url }}/rest/api/3/issue/${ticket_key}" \
|
||||||
response=$(curl \
|
|
||||||
--request PUT \
|
|
||||||
--url "${{ inputs.jira_base_url }}/rest/api/3/issue/$ticket_key" \
|
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
||||||
--header 'Accept: application/json' \
|
--header 'Accept: application/json' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data '{ "fields": { "priority": { "id": "1" } } }'
|
--data '{ "fields": { "priority": { "id": "1" } } }'
|
||||||
)
|
`,
|
||||||
|
{ encoding: 'utf8' }
|
||||||
|
);
|
||||||
|
|
||||||
echo $response
|
console.log(`Response on priority change: ${response}`);
|
||||||
|
|
||||||
# Update ticket status so that squad members can see it in their respective sprints
|
// Update ticket status to NEED REFINEMENT and then SPRINT READY so that squad members can see it in their respective sprints
|
||||||
for transition_id in 11 21; do
|
for (const transition_id of [11, 21]) {
|
||||||
response=$(curl \
|
response = execSync(
|
||||||
--request POST \
|
`curl --request POST \
|
||||||
--url "${{ inputs.jira_base_url }}/rest/api/latest/issue/$ticket_key/transitions" \
|
--url "${{ inputs.jira_base_url }}/rest/api/latest/issue/${ticket_key}/transitions" \
|
||||||
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
--user "${{ inputs.jira_user_email }}:${{ inputs.jira_api_token }}" \
|
||||||
--header 'Accept: application/json' \
|
--header 'Accept: application/json' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data "{\"transition\": {\"id\": \"$transition_id\"} }"
|
--data '{"transition": {"id": "${transition_id}"} }'
|
||||||
|
`,
|
||||||
|
{ encoding: 'utf8' }
|
||||||
)
|
)
|
||||||
|
|
||||||
echo $response
|
console.log(`Response on ticket status change: ${response}`);
|
||||||
done
|
}
|
||||||
|
}
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"content": [
|
"content": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": "This incident ticket relates to the @MODULE_NAME@ nightly on the @GITHUB_BRANCH@ branch which failed on @DATE@."
|
"text": "This incident ticket relates to the @MODULE_NAME@ nightly on the @GITHUB_BRANCH@ branch which failed on @DATE@. This ticket covers the failure on @FAILED_JOB@."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -41,15 +41,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "paragraph",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"text": "List of jobs that failed on the @MODULE_NAME@ nightly:"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
92
.github/workflows/plugins.yml
vendored
92
.github/workflows/plugins.yml
vendored
@ -115,20 +115,6 @@ jobs:
|
|||||||
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Create Jira ticket on 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: "monitoring-plugins"
|
|
||||||
ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]'
|
|
||||||
ticket_squad: "DevSecOps"
|
|
||||||
|
|
||||||
unit-tests:
|
unit-tests:
|
||||||
needs: [get-environment, get-plugins]
|
needs: [get-environment, get-plugins]
|
||||||
if: |
|
if: |
|
||||||
@ -188,20 +174,6 @@ jobs:
|
|||||||
path: ./lastlog.jsonl
|
path: ./lastlog.jsonl
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
- name: Create Jira ticket on 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: "monitoring-plugins"
|
|
||||||
ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]'
|
|
||||||
ticket_squad: "Connectors"
|
|
||||||
|
|
||||||
fatpacker:
|
fatpacker:
|
||||||
needs: [get-environment, get-plugins, unit-tests]
|
needs: [get-environment, get-plugins, unit-tests]
|
||||||
if: |
|
if: |
|
||||||
@ -361,20 +333,6 @@ jobs:
|
|||||||
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
|
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
|
||||||
stability: ${{ needs.get-environment.outputs.stability }}
|
stability: ${{ needs.get-environment.outputs.stability }}
|
||||||
|
|
||||||
- name: Create Jira ticket on 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: "monitoring-plugins"
|
|
||||||
ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]'
|
|
||||||
ticket_squad: "DevSecOps"
|
|
||||||
|
|
||||||
test-plugins:
|
test-plugins:
|
||||||
needs: [get-environment, get-plugins, package]
|
needs: [get-environment, get-plugins, package]
|
||||||
if: |
|
if: |
|
||||||
@ -438,20 +396,6 @@ jobs:
|
|||||||
path: /var/log/robot-plugins-installation-tests.log
|
path: /var/log/robot-plugins-installation-tests.log
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
- name: Create Jira ticket on 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: "monitoring-plugins"
|
|
||||||
ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]'
|
|
||||||
ticket_squad: "Connectors"
|
|
||||||
|
|
||||||
deliver-packages:
|
deliver-packages:
|
||||||
needs: [get-environment, get-plugins, test-plugins]
|
needs: [get-environment, get-plugins, test-plugins]
|
||||||
if: |
|
if: |
|
||||||
@ -496,20 +440,6 @@ jobs:
|
|||||||
release_type: ${{ needs.get-environment.outputs.release_type }}
|
release_type: ${{ needs.get-environment.outputs.release_type }}
|
||||||
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
|
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
|
||||||
|
|
||||||
- name: Create Jira ticket on 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: "monitoring-plugins"
|
|
||||||
ticket_labels: '["Nightly", "Pipeline", "nightly-${{ github.ref_name }}", "${{ github.job }}"]'
|
|
||||||
ticket_squad: "DevSecOps"
|
|
||||||
|
|
||||||
deliver-sources:
|
deliver-sources:
|
||||||
needs: [get-environment, fatpacker]
|
needs: [get-environment, fatpacker]
|
||||||
if: |
|
if: |
|
||||||
@ -571,3 +501,25 @@ jobs:
|
|||||||
! contains(needs.*.result, 'failure') &&
|
! contains(needs.*.result, 'failure') &&
|
||||||
! contains(needs.*.result, 'cancelled')
|
! contains(needs.*.result, 'cancelled')
|
||||||
uses: ./.github/workflows/set-pull-request-skip-label.yml
|
uses: ./.github/workflows/set-pull-request-skip-label.yml
|
||||||
|
|
||||||
|
create-jira-nightly-ticket:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
needs: [
|
||||||
|
get-environment,
|
||||||
|
deliver-packages
|
||||||
|
]
|
||||||
|
if: |
|
||||||
|
needs.get-environment.outputs.is_nightly == 'true' && github.run_attempt == 1 &&
|
||||||
|
(failure() || cancelled() || contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled'))
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
|
|
||||||
|
- name: Create Jira ticket based on nightly build failure
|
||||||
|
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-plugins"
|
||||||
|
ticket_reason_for_creation: "Nightly"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user