Commit 314997f6 authored by Alexandros Valantasis's avatar Alexandros Valantasis
Browse files

fix: Edit .gitlab-ci.yml

parent 84ca6079
Loading
Loading
Loading
Loading
+19 −51
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ variables:
  DOCKER_TLS_CERTDIR: ""
  DOCKER_DRIVER: overlay2
  DOCKER_API_VERSION: "1.41"
  DEPLOYMENT_SERVER_IP: "192.168.5.185"
  DEPLOYMENT_SERVER_USER: "ubuntu"
  TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX: "registry.ubitech.eu/nsit/maestro-apps/"
  IMAGE_NAME: "telemetry-api-jvm"
  MAVEN_REPO: "${CI_PROJECT_ROOT_NAMESPACE}/.m2/repository"
@@ -29,17 +27,6 @@ variables:
  SONAR_USER_HOME: "${CI_PROJECT_ROOT_NAMESPACE}/${CI_PROJECT_NAME}/.sonar"
  MAVEN_CLI_OPTS_SONAR: "-s .ci-settings.xml --no-transfer-progress"
  MAVEN_CLI_OPTS: "-s .ci-settings.xml --no-transfer-progress"
  HELM_INSTALLER_REPO: "gitlab.ubitech.eu/maestro-v2/installer/io.maestro.installer.orchestrator.helm.git"
  DEV_SONATA_CORE_IMAGE: "registry.ubitech.eu/maestro-v2/sonata/io.maestro.sonata.core/sonata-core-jvm:latest"
  DEV_SONATA_OSS_IMAGE: "registry.ubitech.eu/maestro-v2/io.maestro.clients/io.maestro.clients.oss/oss-client-jvm:latest"
  DEV_SONATA_HELM_IMAGE: "registry.ubitech.eu/maestro-v2/sonata/sonata.engine.helm/helm-engine:latest"
  DEV_ZTC_CLIENT_IMAGE: "registry.ubitech.eu/maestro-v2/io.maestro.clients/io.maestro.clients.ztc/ztc-client:latest"
  DEV_TMF_API_IMAGE: "registry.ubitech.eu/maestro-v2/api/io.maestro.api.tmf.api/tmf-api-jvm:latest"
  DEV_PORTAL_CART_IMAGE: "registry.ubitech.eu/maestro-v2/io.maestro.portal/io.maestro.portal.cart/maestro-portal-jvm:latest"
  DEV_PEERING_IMAGE: "registry.ubitech.eu/maestro-v2/api/io.maestro.api.peering/peering-api-jvm:latest"
  DEV_REGISTRY_IMAGE: "registry.ubitech.eu/maestro-v2/api/io.maestro.api.registry/registry-api-jvm:latest"
  DEV_FABRIC_IMAGE: "registry.ubitech.eu/maestro-v2/api/io.maestro.api.fabric/fabric-api-jvm:latest"
  DEV_PORTAL: "registry.ubitech.eu/maestro-v2/io.maestro.portal/maestro-portal/maestro-portal:latest"

cache:
  key: "${CI_PROJECT_ROOT_NAMESPACE}"
@@ -164,75 +151,55 @@ dev_image_build_job:
dev_deploy_job:
  stage: dev_deploy
  image:
    name: registry.ubitech.eu/nsit/maestro-apps/python:3.9
    name: registry.ubitech.eu/nsit/maestro-apps/python-argocd:3.9
    pull_policy: [always, if-not-present]
  before_script:
    - apt-get update && apt-get install -y curl && apt-get install -y jq
    - python3 -m pip install ruamel.yaml
    - curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/download/v2.13.5/argocd-linux-amd64
    - install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
    - git clone https://oauth2:$INSTALLER_TOKEN@gitlab.ubitech.eu/maestro-v2/installer/io.maestro.installer.orchestrator.helm.git
    - git clone --depth 1 --branch gitops-cd https://oauth2:$INSTALLER_TOKEN@$INSTALLER_REPO
    - cd io.maestro.installer.orchestrator.helm
    - git checkout gitops-cd
    - git pull origin gitops-cd

  script:
    - python3 scripts/helm_update.py $CI_REGISTRY/$CI_PROJECT_PATH/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA $DEV_SONATA_CORE_IMAGE $DEV_SONATA_OSS_IMAGE $DEV_SONATA_HELM_IMAGE $DEV_ZTC_CLIENT_IMAGE $DEV_PORTAL_CART_IMAGE $DEV_TMF_API_IMAGE $DEV_PEERING_IMAGE $DEV_REGISTRY_IMAGE $DEV_FABRIC_IMAGE $DEV_PORTAL
    - git add .
    - git config --global user.email "avalantasis@ubitech.eu"
    - git config --global user.name "avalantasis"
    - git config --global user.email "$GITLAB_USER_NAME"
    - git config --global user.name "$GITLAB_USER_EMAIL"

    - |
      if git commit -m "Update values.yaml for GitOps CD [skip ci]"; then
        git push origin gitops-cd
      else
        echo "No changes to commit."
      fi
    - |
      argocd login $ARGOCD_SERVER --username $ARGOCD_USERNAME --password $ARGOCD_PASSWORD --insecure
      argocd app sync maestro --timeout 300

      APP_STATUS=$(argocd app get maestro -o json | jq -r '.status.health.status')
      SYNCED=$(argocd app get maestro -o json | jq -r '.status.sync.status')

      if [[ "$SYNCED" != "Synced" ]]; then
        echo "Application sync status is not Synced. Exiting."
        exit 1
      fi
    - |
      set -e
      argocd login "$ARGOCD_SERVER" --username "$ARGOCD_USERNAME" --password "$ARGOCD_PASSWORD" --insecure
      argocd app get maestro --refresh >/dev/null
      argocd app wait maestro --sync --health --timeout 120
      echo "Argo CD application 'maestro' is synced and healthy."

      if [ "$APP_STATUS" != "Healthy" ]; then
        echo "Argo CD application 'maestro' is not healthy. Current status: $APP_STATUS"
        exit 1
      fi
      echo "Argo CD application 'maestro' is healthy."
  dependencies:
     - dev_image_build_job
  rules:
     - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'



dev_workflows_job:
  stage: dev_workflows
  image:
    name: registry.ubitech.eu/nsit/maestro-apps/docker:20.10.16
  services:
    - name: registry.ubitech.eu/nsit/maestro-apps/docker:20.10.16-dind
      command: [ "--tls=false" ]
      alias: docker
    name: registry.ubitech.eu/nsit/maestro-apps/newman-ci:latest
  before_script:
    - docker info > /dev/null
    - apk update && apk add git
    - git clone https://oauth2:$COLLECTION_TOKEN@gitlab.ubitech.eu/maestro-v2/io.maestro.cd/io.maestro.cd.collections.git
    - git clone --depth 1 https://oauth2:$COLLECTION_TOKEN@$COLLECTION_REPO
    - cp io.maestro.cd.collections/files/collection.json .
    - cp io.maestro.cd.collections/files/env.json .
    - echo "$MAESTRO_APPS_TOKEN" | docker login $MAESTRO_APPS_REGISTRY -u $MAESTRO_APPS_USER --password-stdin
  script:
    #- sleep 120
    - ls -l
    - docker run -v $(pwd):/etc/newman -t registry.ubitech.eu/nsit/maestro-apps/postman/newman:latest run /etc/newman/collection.json --environment /etc/newman/env.json
    - newman run collection.json --environment env.json
  dependencies:
    - dev_deploy_job
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'


prod_extract_next_release_job:
  image: 
    name: registry.ubitech.eu/nsit/maestro-apps/node:lts
@@ -279,7 +246,8 @@ prod_package_job:
    - git config --global user.name $GITLAB_USER_NAME
    - |
      if git commit -m "Release $DEV_RELEASE_VERSION: Update project version [skip ci]"; then
        git push -f "https://$GITLAB_USER_NAME:$GITLAB_TOKEN_SEMANTIC_VERSIONING@gitlab.ubitech.eu/maestro-v2/mdg-hypo/org.etsi.osl.hypo.clients/org.etsi.osl.hypo.clients.telemetry.git" HEAD:main
        git remote set-url origin "https://${GITLAB_USER_NAME}:${GITLAB_TOKEN_SEMANTIC_VERSIONING}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
        git push -f origin HEAD:main
      else
        echo "No changes to commit."
      fi