From ac65fd0ddc9db6a5e098d4bf986c82025812f8c5 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Mon, 9 Oct 2023 09:21:46 +0200 Subject: [PATCH] enh(ci): move all deliveries to artifactory (#4687) * move all deliveries to artifactory * do not delivery nrpe service configuration Refs: MON-22360 --- .../actions/deb-delivery-legacy/action.yml | 34 ++++---- .github/actions/deb-delivery/action.yml | 19 ++-- .github/actions/release-sources/action.yml | 3 +- .../actions/rpm-delivery-legacy/action.yml | 86 +++++++------------ .github/actions/rpm-delivery/action.yml | 2 +- .github/workflows/connector-vmware.yml | 3 +- .github/workflows/nrpe.yml | 3 +- .github/workflows/perl-vmware-vsphere.yml | 3 +- .github/workflows/plugin-delivery.yml | 26 +----- .github/workflows/plugins.yml | 6 -- nrpe/packaging/centreon-nrpe3-daemon.yaml | 4 +- .../{nrpe3.service.deb => nrpe3.deb.service} | 0 .../{nrpe3.service.rpm => nrpe3.rpm.service} | 0 13 files changed, 74 insertions(+), 115 deletions(-) rename nrpe/packaging/files/{nrpe3.service.deb => nrpe3.deb.service} (100%) rename nrpe/packaging/files/{nrpe3.service.rpm => nrpe3.rpm.service} (100%) diff --git a/.github/actions/deb-delivery-legacy/action.yml b/.github/actions/deb-delivery-legacy/action.yml index 624b048cd..53fa62794 100644 --- a/.github/actions/deb-delivery-legacy/action.yml +++ b/.github/actions/deb-delivery-legacy/action.yml @@ -1,24 +1,24 @@ name: "deb-delivery-legacy" description: "Deliver legacy DEB packages" inputs: + module_name: + description: "The package module name" + required: true distrib: description: "The distribution used for packaging" required: true major_version: description: "The major version" required: true - nexus_username: - description: The nexus username - required: true - nexus_password: - description: The nexus password - required: true cache_key: description: "The cached package key" required: true stability: description: "The package stability (stable, testing, unstable)" required: true + artifactory_token: + description: "token for artifactory" + required: true runs: using: "composite" @@ -30,18 +30,20 @@ runs: key: ${{ inputs.cache_key }} fail-on-cache-miss: true - - name: Publish DEBs to Nexus + - uses: jfrog/setup-jfrog-cli@v3 + env: + JF_URL: https://centreon.jfrog.io + JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }} + + - name: Publish DEBs to artifactory run: | - echo "Delivering to ${{ inputs.major_version }} ${{ inputs.stability }}" + FILES="*.deb" - FOLDER_SUFFIX="-${{ inputs.stability }}" - if [[ "${{ inputs.stability }}" == "stable" ]]; then - FOLDER_SUFFIX="" - fi + for FILE in $FILES; do + echo "[DEBUG] - File: $FILE" - for FILE in *.deb; do - sleep 2 - echo "Delivering $FILE" - curl --connect-timeout 10 --retry 2 --retry-max-time 30 --fail --silent --show-error -u '${{ inputs.nexus_username }}':'${{ inputs.nexus_password }}' -H 'Content-Type: multipart/form-data' --data-binary "@./$FILE" https://apt.centreon.com/repository/${{ inputs.major_version }}$FOLDER_SUFFIX/ || echo "::error::Fail to deliver $FILE ${{ inputs.major_version }}" + ARCH=$(echo $FILE | cut -d '_' -f3 | cut -d '.' -f1) + + jf rt upload "$FILE" "apt-standard-${{ inputs.major_version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH" done shell: bash diff --git a/.github/actions/deb-delivery/action.yml b/.github/actions/deb-delivery/action.yml index 9faad28cd..be041ce3b 100644 --- a/.github/actions/deb-delivery/action.yml +++ b/.github/actions/deb-delivery/action.yml @@ -1,15 +1,12 @@ name: "deb-delivery" description: "Deliver DEB packages" inputs: + module_name: + description: "The package module name" + required: true distrib: description: "The distribution used for packaging" required: true - nexus_username: - description: The nexus username - required: true - nexus_password: - description: The nexus password - required: true cache_key: description: "The cached package key" required: true @@ -37,5 +34,13 @@ runs: - name: Publish DEBs to artifactory run: | - jf rt upload "*.deb" "apt-plugins-${{ inputs.stability }}/pool/" --deb "${{ inputs.distrib }}/main/all" + FILES="*.deb" + + for FILE in $FILES; do + echo "[DEBUG] - File: $FILE" + + ARCH=$(echo $FILE | cut -d '_' -f3 | cut -d '.' -f1) + + jf rt upload "$FILE" "apt-plugins-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH" + done shell: bash diff --git a/.github/actions/release-sources/action.yml b/.github/actions/release-sources/action.yml index d414ea676..28e62b3f8 100644 --- a/.github/actions/release-sources/action.yml +++ b/.github/actions/release-sources/action.yml @@ -30,7 +30,8 @@ runs: sudo ./aws/install shell: bash - - run: | + - name: Publish on download.centreon.com + run: | SRC_FILE="${{ inputs.module_name }}-${{ inputs.version }}.tar.gz" mv "${{ inputs.module_directory }}" "${{ inputs.module_name }}-${{ inputs.version }}" diff --git a/.github/actions/rpm-delivery-legacy/action.yml b/.github/actions/rpm-delivery-legacy/action.yml index bf7b7ff41..39578cd10 100644 --- a/.github/actions/rpm-delivery-legacy/action.yml +++ b/.github/actions/rpm-delivery-legacy/action.yml @@ -13,24 +13,12 @@ inputs: cache_key: description: "The cached package key" required: true - yum_repo_url: - description: "The legacy yum repo url" - required: true - update_repo_path: - description: "The update repo script path" - required: true - cloudfront_id: - description: "The cloudfront ID for repo url" - required: true - yum_repo_address: - description: "The legacy yum repo address" - required: true - yum_repo_key: - description: "The repo key" - required: true stability: description: "The package stability (stable, testing, unstable)" required: true + artifactory_token: + description: "token for artifactory" + required: true runs: using: "composite" @@ -42,56 +30,46 @@ runs: key: ${{ inputs.cache_key }} fail-on-cache-miss: true - - name: Setup awscli - run: | - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" - sudo unzip -q awscliv2.zip - sudo ./aws/install - shell: bash + - uses: jfrog/setup-jfrog-cli@v3 + env: + JF_URL: https://centreon.jfrog.io + JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }} - - name: Publish RPMs to standard repositories + - name: Publish RPMs to standard repository run: | FILES="*.rpm" - REPOTYPE="${{ inputs.stability }}" - PROJECT_PATH="standard" - DISTRIB="${{ inputs.distrib }}" - ARCH="noarch" + echo "[DEBUG] - Distrib: ${{ inputs.distrib }}" - eval `ssh-agent` - ssh-add - <<< "${{ inputs.yum_repo_key }}" - - echo "Delivering to ${{ inputs.major_version }} $REPOTYPE" - - if [ "$REPOTYPE" == "stable" ]; then - TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/RPMS" - else - TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}" - PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}" + if [ -z "${{ inputs.module_name }}" ]; then + echo "::error::Module name is required" + exit 1 fi - echo "[DEBUG] - Target : $TARGET" - echo "[DEBUG] - PROJECT_LOCATION : $PROJECT_LOCATION" + if [ -z "${{ inputs.distrib }}" ]; then + echo "::error::Distrib is required" + exit 1 + fi - ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" mkdir -p "$TARGET" - scp -o StrictHostKeyChecking=no ./*.rpm "${{ inputs.yum_repo_address }}:$TARGET" + mkdir noarch x86_64 - # Update repository metadata - METADATAS="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH" - sleep $((RANDOM % 120)) # wait random time to avoid simultaneous createrepo - ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "sh "${{ inputs.update_repo_path }}" $METADATAS" 2>&- + for FILE in $FILES; do + echo "[DEBUG] - File: $FILE" - # Invalidate cloudfront cache - ID="${{ inputs.cloudfront_id }}" - PATHS="/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/*" - ITERATIONS=1 + ARCH=$(echo $FILE | grep -oP '(x86_64|noarch)') - until aws cloudfront create-invalidation --distribution-id "$ID" --paths "$PATHS"; do - if [ ${ITERATIONS} -eq 10 ]; then - return 0 + echo "[DEBUG] - Arch: $ARCH" + + cp "$FILE" "$ARCH" + done + + for ARCH in "noarch" "x86_64"; do + if [ "$(ls -A $ARCH)" ]; then + if [ "${{ inputs.stability }}" == "stable" ]; then + jf rt upload "$ARCH/*.rpm" "rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat + else + jf rt upload "$ARCH/*.rpm" "rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat + fi fi - echo "couldn't invalidate cache, AWS quota might have been reached, retrying in 30 seconds..." - sleep 30s - ITERATIONS=$((ITERATIONS+1)) done shell: bash diff --git a/.github/actions/rpm-delivery/action.yml b/.github/actions/rpm-delivery/action.yml index 94622ce2d..022380cc3 100644 --- a/.github/actions/rpm-delivery/action.yml +++ b/.github/actions/rpm-delivery/action.yml @@ -63,7 +63,7 @@ runs: for ARCH in "noarch" "x86_64"; do if [ "$(ls -A $ARCH)" ]; then if [ "${{ inputs.stability }}" == "stable" ]; then - jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/" --flat + jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat else jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat fi diff --git a/.github/workflows/connector-vmware.yml b/.github/workflows/connector-vmware.yml index 0bf89181d..47206aad6 100644 --- a/.github/workflows/connector-vmware.yml +++ b/.github/workflows/connector-vmware.yml @@ -17,8 +17,6 @@ on: paths: - 'connectors/vmware/src/**' - 'connectors/vmware/packaging/**' - tags: - - centreon-connector-vmware-* jobs: get-environment: @@ -111,6 +109,7 @@ jobs: - name: Delivery uses: ./.github/actions/deb-delivery with: + module_name: connector-vmware distrib: ${{ matrix.distrib }} cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }} stability: ${{ needs.get-environment.outputs.stability }} diff --git a/.github/workflows/nrpe.yml b/.github/workflows/nrpe.yml index 01b01d140..64ebca44f 100644 --- a/.github/workflows/nrpe.yml +++ b/.github/workflows/nrpe.yml @@ -15,8 +15,6 @@ on: - master paths: - 'nrpe/packaging/**' - tags: - - centreon-nrpe-* jobs: get-environment: @@ -147,6 +145,7 @@ jobs: - name: Delivery uses: ./.github/actions/deb-delivery with: + module_name: nrpe distrib: ${{ matrix.distrib }} cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }} stability: ${{ needs.get-environment.outputs.stability }} diff --git a/.github/workflows/perl-vmware-vsphere.yml b/.github/workflows/perl-vmware-vsphere.yml index 63b74a765..d0623409e 100644 --- a/.github/workflows/perl-vmware-vsphere.yml +++ b/.github/workflows/perl-vmware-vsphere.yml @@ -15,8 +15,6 @@ on: - master paths: - 'dependencies/perl-vmware-vsphere/**' - tags: - - perl-vmware-vsphere-* jobs: get-environment: @@ -136,6 +134,7 @@ jobs: - name: Delivery uses: ./.github/actions/deb-delivery with: + module_name: perl-vmware-vsphere distrib: ${{ matrix.distrib }} cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }} stability: ${{ needs.get-environment.outputs.stability }} diff --git a/.github/workflows/plugin-delivery.yml b/.github/workflows/plugin-delivery.yml index 75e45f6cf..37dfb02df 100644 --- a/.github/workflows/plugin-delivery.yml +++ b/.github/workflows/plugin-delivery.yml @@ -14,22 +14,6 @@ on: type: string required: true secrets: - nexus_username: - required: true - nexus_password: - required: true - update_repo_path: - description: "The update repo script path" - required: true - cloudfront_id: - description: "The cloudfront ID for repo url" - required: true - yum_repo_address: - description: "The legacy yum repo address" - required: true - yum_repo_key: - description: "The repo key" - required: true artifactory_token: description: "The artifactory token" required: true @@ -102,11 +86,8 @@ jobs: major_version: ${{ matrix.major_version }} distrib: ${{ matrix.distrib }} cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }} - update_repo_path: ${{ secrets.update_repo_path }} - cloudfront_id: ${{ secrets.cloudfront_id }} - yum_repo_address: ${{ secrets.yum_repo_address }} - yum_repo_key: ${{ secrets.yum_repo_key }} stability: ${{ inputs.stability }} + artifactory_token: ${{ secrets.artifactory_token }} deliver-deb: runs-on: [self-hosted, common] @@ -122,6 +103,7 @@ jobs: - name: Delivery uses: ./.github/actions/deb-delivery with: + module_name: plugins distrib: ${{ matrix.distrib }} cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }} stability: ${{ inputs.stability }} @@ -143,12 +125,12 @@ jobs: - name: Delivery uses: ./.github/actions/deb-delivery-legacy with: + module_name: plugins distrib: ${{ matrix.distrib }} major_version: ${{ matrix.major_version }} - nexus_username: ${{ secrets.nexus_username }} - nexus_password: ${{ secrets.nexus_password }} cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }} stability: ${{ inputs.stability }} + artifactory_token: ${{ secrets.artifactory_token }} release-tag: if: ${{ inputs.stability == 'stable' && github.event_name == 'push' }} diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index afe9ec332..c9f14b37b 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -235,11 +235,5 @@ jobs: release: ${{ needs.get-environment.outputs.release }} stability: ${{ needs.get-environment.outputs.stability }} secrets: - nexus_username: ${{ secrets.NEXUS_USERNAME }} - nexus_password: ${{ secrets.NEXUS_PASSWORD }} - update_repo_path: ${{ secrets.UPDATE_REPO_PATH }} - cloudfront_id: ${{ secrets.CLOUDFRONT_ID }} - yum_repo_address: ${{ secrets.YUM_REPO_ADDRESS }} - yum_repo_key: ${{ secrets.YUM_REPO_KEY }} artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }} diff --git a/nrpe/packaging/centreon-nrpe3-daemon.yaml b/nrpe/packaging/centreon-nrpe3-daemon.yaml index f5b69df2e..f7158b754 100644 --- a/nrpe/packaging/centreon-nrpe3-daemon.yaml +++ b/nrpe/packaging/centreon-nrpe3-daemon.yaml @@ -36,12 +36,12 @@ contents: file_info: mode: 0644 - - src: "files/nrpe3.service.rpm" + - src: "files/nrpe3.rpm.service" dst: "/lib/systemd/system/centreon-nrpe3.service" packager: rpm file_info: mode: 0644 - - src: "files/nrpe3.service.deb" + - src: "files/nrpe3.deb.service" dst: "/lib/systemd/system/centreon-nrpe3.service" packager: deb file_info: diff --git a/nrpe/packaging/files/nrpe3.service.deb b/nrpe/packaging/files/nrpe3.deb.service similarity index 100% rename from nrpe/packaging/files/nrpe3.service.deb rename to nrpe/packaging/files/nrpe3.deb.service diff --git a/nrpe/packaging/files/nrpe3.service.rpm b/nrpe/packaging/files/nrpe3.rpm.service similarity index 100% rename from nrpe/packaging/files/nrpe3.service.rpm rename to nrpe/packaging/files/nrpe3.rpm.service