From 427967154d879aad1f9ef64abdf782ed1a151974 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Fri, 29 Nov 2024 16:02:34 +0100 Subject: [PATCH] Feature 11048: Publication of OSM packages as public VNF catalog Signed-off-by: garciadeblas --- .gitlab-ci.yml | 121 +++++++++++++++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 43 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e063c1..3ff4dec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,54 +1,89 @@ ############################################################################### -publish-repository: - # Builds the repository and pushes it to ftp site when a MR is accepted - image: ubuntu:22.04 - stage: deploy - script: - - DEBIAN_FRONTEND=noninteractive apt update - - DEBIAN_FRONTEND=noninteractive apt install -y gcc git make python3 python3 python3-pip python3-pycurl python3-setuptools sshpass software-properties-common wget - - git submodule init - - git submodule update - - git clone https://osm.etsi.org/gerrit/osm/osmclient.git - - pip3 install -r osmclient/requirements.txt -r osmclient/requirements-dev.txt - - pip3 install osmclient/ - - rm -rf osmclient/ - - ./generate-packages.sh - - mkdir temp - # - mv magma/* temp - - mv *.tar.gz charm-packages/*.tar.gz temp - - LC_ALL=C.UTF-8 LANG=C.UTF-8 osm -vvv repo-index --origin temp --destination vnf-catalog - # - | - # sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P 29419 osmsupport@vnf-catalog.etsi.org << EOF - # put -r vnf-catalog/* Testing - # EOF - rules: - - if: '$CI_COMMIT_REF_PROTECTED == "true"' - when: on_success +# Global variables +############################################################################### +variables: + DEBIAN_FRONTEND: "noninteractive" + LC_ALL: "C.UTF-8" + LANG: "C.UTF-8" + REPOSITORY_URL: "https://osm.etsi.org/gerrit/osm/osmclient.git" + SFTP_SERVER: "vnf-catalog.etsi.org" + SFTP_PORT: "29419" + SFTP_USER: "osmsupport" + ONDEMAND_DESTINATION_FOLDER: "Stable" + +############################################################################### +# Anchor definition with common commands +############################################################################### +.default-script: &default_script + - apt update && apt install -y gcc git make python3 python3 python3-pip python3-pycurl python3-setuptools software-properties-common wget + - git submodule init + - git submodule update + - git clone https://osm.etsi.org/gerrit/osm/osmclient.git + - pip3 install -r osmclient/requirements.txt -r osmclient/requirements-dev.txt + - pip3 install osmclient/ + - rm -rf osmclient/ + - ./generate-packages.sh + - mkdir temp + # - mv magma/* temp + - mv *.tar.gz charm-packages/*.tar.gz temp + - osm -vvv repo-index --origin temp --destination vnf-catalog + - rm -rf temp +############################################################################### +# Job to build artifacts ############################################################################### build-local-repository: # Builds the repository locally but does not push if this is a new MR that # is still in development image: python:3.10 stage: build + script: *default_script + artifacts: + paths: + - vnf-catalog/ + # rules: + # - if: '$CI_COMMIT_REF_PROTECTED == "false"' + # when: on_success + +############################################################################### +# Job to publish artifacts on successful merge (publication to Testing) +############################################################################### +publish-testing-repository: + # Builds the repository and pushes it to ftp site when a MR is accepted + image: ubuntu:22.04 + stage: deploy + dependencies: + - build-local-repository # Reuses artifacts generated in build los artefactos generados en build script: - - DEBIAN_FRONTEND=noninteractive apt update - - DEBIAN_FRONTEND=noninteractive apt install -y gcc git make python3 python3 python3-pip python3-pycurl python3-setuptools sshpass software-properties-common wget - - git submodule init - - git submodule update - - git clone https://osm.etsi.org/gerrit/osm/osmclient.git - - pip3 install -r osmclient/requirements.txt -r osmclient/requirements-dev.txt - - pip3 install osmclient/ - - rm -rf osmclient/ - - ./generate-packages.sh - - mkdir temp - # - mv magma/* temp - - mv *.tar.gz charm-packages/*.tar.gz temp - - LC_ALL=C.UTF-8 LANG=C.UTF-8 osm -vvv repo-index --origin temp --destination vnf-catalog - # - | - # sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P 29419 osmsupport@vnf-catalog.etsi.org << EOF - # put -r vnf-catalog/* Testing/Premerge - # EOF + - apt update && apt install -y sshpass + - | + sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P $SFTP_PORT $SFTP_USER@$SFTP_SERVER << EOF + put -r vnf-catalog/* Testing + EOF rules: - - if: '$CI_COMMIT_REF_PROTECTED == "false"' + - if: '$CI_COMMIT_REF_NAME == "master"' # Only in master when: on_success + # - if: '$CI_COMMIT_REF_PROTECTED == "true"' + # when: on_success + +############################################################################### +# Job to publish artifacts on demand (publication to Testing) +############################################################################### +publish-ondemand-repository: + image: ubuntu:22.04 + stage: deploy + dependencies: + - build-local-repository + script: + - apt update && apt install -y sshpass + - | + DESTINATION_FOLDER="${ONDEMAND_DESTINATION_FOLDER:-Testing}" + echo "Uploading files to folder $DESTINATION_FOLDER in FTP ..." + sshpass -p "$VNF_CATALOG_CREDENTIALS" sftp -o "StrictHostKeyChecking no" -P $SFTP_PORT $SFTP_USER@$SFTP_SERVER << EOF + put -r vnf-catalog/* $DESTINATION_FOLDER + EOF + when: manual # This job is run on demand + allow_failure: true + environment: + name: production + url: "ftp://$SFTP_SERVER/$DESTINATION_FOLDER" -- GitLab