Commit 479a11ea authored by Christos Tranoris's avatar Christos Tranoris
Browse files

modified gitlabb ci

parent 28afdd25
Loading
Loading
Loading
Loading
Loading
+11 −23
Changes for .gitlab-ci.yml: 11 added lines, 23 removed lines.
Original line number Diff line number Diff line
# Builds and pushes a Docker image to Harbor whenever a Git tag is pushed.
# The tag name becomes the image tag, e.g. pushing tag "v1.4.0" publishes
# ${HARBOR_REGISTRY}/${HARBOR_PROJECT}/${CI_PROJECT_NAME}:v1.4.0
# Builds and pushes a Docker image to this project's GitLab container registry
# whenever a Git tag is pushed. The tag name becomes the image tag, e.g. pushing
# tag "v1.4.0" publishes ${CI_REGISTRY_IMAGE}:v1.4.0 (and moves :latest), i.e.
# labs.etsi.org:5050/osl/utilities/org.etsi.osl.util.controllers.testharness:v1.4.0
#
# The Dockerfile expects a pre-built jar (it COPYs target/*.jar rather than
# building from source), so this pipeline runs `mvn package` first and hands
# the jar to the image-build stage as an artifact.
#
# Required CI/CD variables (set once at the `openslice` group level so every
# repo in the group inherits them — Settings > CI/CD > Variables):
#   HARBOR_REGISTRY      e.g. "harbor.intranet.pnet"
#   HARBOR_PROJECT        e.g. "osl-staging"       (Harbor project/namespace)
#   HARBOR_ROBOT_USER      Harbor robot account, e.g. "robot$osl-staging+gitlab-ci"
#   HARBOR_ROBOT_TOKEN     the robot account's token
# Mark HARBOR_ROBOT_USER and HARBOR_ROBOT_TOKEN as "Protected" + "Masked", and
# protect the tag pattern you release with (Settings > Repository > Protected
# tags) so the variables are only ever exposed to a tag pipeline.
#
# harbor.intranet.pnet currently serves plain HTTP only (no TLS listener on
# 443), so the push below runs with Kaniko's --insecure flag. That means the
# robot account credentials and image layers cross the network unencrypted —
# acceptable only because this stays on the trusted intranet segment. Drop
# --insecure once Harbor is put behind TLS.
# Registry login uses GitLab's predefined CI_REGISTRY, CI_REGISTRY_USER and
# CI_REGISTRY_PASSWORD, so no CI/CD variables need to be configured. The
# project's Container registry must be enabled (Settings > General > Visibility).

stages:
  - build
@@ -48,12 +37,11 @@ docker_build_push:
  rules:
    - if: '$CI_COMMIT_TAG'
  script:
    - echo "Building and pushing ${CI_PROJECT_NAME}:${CI_COMMIT_TAG}"
    - echo "Building and pushing ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
    - >-
      echo "{\"auths\":{\"${HARBOR_REGISTRY}\":{\"auth\":\"$(printf '%s:%s' "${HARBOR_ROBOT_USER}" "${HARBOR_ROBOT_TOKEN}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
      echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf '%s:%s' "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "${HARBOR_REGISTRY}/${HARBOR_PROJECT}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}"
      --destination "${HARBOR_REGISTRY}/${HARBOR_PROJECT}/${CI_PROJECT_NAME}:latest"
      --insecure
      --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
      --destination "${CI_REGISTRY_IMAGE}:latest"