Commit 78850a71 authored by garciadeblas's avatar garciadeblas
Browse files

Feature 11048: Publication of OSM packages as public VNF catalog

parent 3c6679c2
Loading
Loading
Loading
Loading
+78 −43
Original line number Diff line number Diff line
###############################################################################
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
# 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
@@ -16,39 +26,64 @@ publish-repository:
  - 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
  - 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"