Skip to content

Commit

Permalink
MON-160168 Centreon next 23.04 (Jira release #20400#) (#2125)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkippes authored Mar 3, 2025
2 parents 2ade1d5 + 493f878 commit 8018271
Show file tree
Hide file tree
Showing 34 changed files with 812 additions and 307 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ selinux/** @centreon/owners-pipelines

tests/** @centreon/owners-robot-e2e

.version* @centreon/owners-pipelines
gorgone/ @centreon/owners-perl
gorgone/docs/ @centreon/owners-doc

gorgone/tests/robot/config/ @centreon/owners-perl
*.pm @centreon/owners-perl
*.pl @centreon/owners-perl

.github/scripts/*robot* @centreon/owners-robot-e2e
142 changes: 142 additions & 0 deletions .github/actions/create-jira-ticket/action.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/actions/create-jira-ticket/nightly-ticket-template.json
Original file line number Diff line number Diff line change
@@ -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@"
}
}
]
}
]
}
]
}
2 changes: 1 addition & 1 deletion .github/actions/deb-delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
using: "composite"
steps:
- name: Use cache DEB files
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ./*.deb
key: ${{ inputs.cache_key }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ runs:
echo "extfile=deb" >> $GITHUB_ENV
- name: Use cache files
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ./*.${{ env.extfile }}
key: ${{ inputs.cache_key }}
Expand Down
19 changes: 11 additions & 8 deletions .github/actions/package-legacy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ inputs:
package_extension:
description: The package extension (deb or rpm)
required: true
distrib:
description: The distribution
required: true
frontend_index_cache_key:
description: The index.html cache key
frontend_index_file:
Expand Down Expand Up @@ -57,23 +60,23 @@ runs:
steps:
- name: Restore index file cache
if: "${{ inputs.frontend_index_file != '' && inputs.frontend_index_cache_key != '' }}"
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ inputs.frontend_index_file }}
key: ${{ inputs.frontend_index_cache_key }}
fail-on-cache-miss: true

- name: Restore static directory cache
if: "${{ inputs.frontend_static_directory != '' && inputs.frontend_static_cache_key != '' }}"
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ inputs.frontend_static_directory }}
key: ${{ inputs.frontend_static_cache_key }}
fail-on-cache-miss: true

- name: Restore widgets directory cache
if: "${{ inputs.frontend_widgets_directory != '' && inputs.frontend_widgets_cache_key != '' }}"
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ inputs.frontend_widgets_directory }}
key: ${{ inputs.frontend_widgets_cache_key }}
Expand All @@ -87,15 +90,15 @@ runs:
- name: Restore vendor directory cache
if: "${{ inputs.backend_vendor_directory != '' && inputs.backend_vendor_cache_key != '' }}"
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ inputs.backend_vendor_directory }}
key: ${{ inputs.backend_vendor_cache_key }}
fail-on-cache-miss: true

- name: Restore translation directory cache
if: "${{ inputs.translation_directory != '' && inputs.translation_cache_key != '' }}"
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ${{ inputs.translation_directory }}
key: ${{ inputs.translation_cache_key }}
Expand Down Expand Up @@ -166,14 +169,14 @@ runs:
shell: bash

- name: Upload package artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: packages-${{ inputs.package_extension }}
name: packages-${{ inputs.package_extension }}-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension }}
retention-days: 1

- name: Cache packaged files
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}
4 changes: 2 additions & 2 deletions .github/actions/package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ runs:
shell: bash

- name: Cache packages
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}

# 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 }}
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ runs:
# Get previous and new version tags for components
for component in ${COMPONENTS_COLLECT[@]}; do
MAJOR_VERSION=$(grep -E "MAJOR" .version | cut -d '=' -f2)
MINOR_VERSION=$(grep -E "MINOR" .version | cut -d '=' -f2)
if [[ "$component" == "centreon-collect" ]]; then
MINOR_VERSION=$(grep -E "MINOR" .version | cut -d '=' -f2)
else
MINOR_VERSION=$(grep -E "MINOR" .version.$component | cut -d '=' -f2)
fi
# Previous stable tags array
if [[ $RELEASE_CLOUD -eq 1 ]]; then
PREVIOUS_STABLE_TAGS+=($(git tag -l --sort=-version:refname "$component-$CURRENT_STABLE_BRANCH_MAJOR_VERSION.*-*" | head -n 1))
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/rpm-delivery/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
using: "composite"
steps:
- name: Use cache RPM files
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ./*.rpm
key: ${{ inputs.cache_key }}
Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma8
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dnf install -y cmake \
perl-interpreter \
rpm-build \
zstd \
nfpm
nfpm-2.41.1

dnf update libarchive

Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma9
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dnf --best install -y cmake \
rpm-build \
procps-ng \
zstd \
nfpm \
nfpm-2.41.1 \
sudo

# TEMPORARY PYTHON UPGRADE TO 3.18 TO HELP WITH DATA_FILTER ISSUE
Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-debian-bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ apt-get -y install cmake \

echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
apt-get update
apt-get install -y nfpm
apt-get install -y nfpm=2.41.1

apt-get clean

Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-mysql-alma9
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dnf --best install -y cmake \
rpm-build \
procps-ng \
zstd \
nfpm \
nfpm-2.41.1 \
sudo

pip3 install conan==1.64.0 --prefix=/usr --upgrade
Expand Down
Loading

0 comments on commit 8018271

Please sign in to comment.