Commit 687bf50f authored by Christos Tranoris's avatar Christos Tranoris
Browse files

fix ci

parent 3f51bc23
Loading
Loading
Loading
Loading
Loading
+12 −24
Changes for .gitlab-ci.yml: 12 added lines, 24 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}/org.etsi.osl.chronos: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/code/addons/chronos/org.etsi.osl.chronos:v1.4.0
#
# The Dockerfile is multi-stage and builds the jar from source itself
# (`mvn package -DskipTests` in its builder stage). The `maven_build` job below
@@ -8,24 +9,12 @@
# the image is only built and pushed if it passes. Its jar artifact is not used
# by the image build.
#
# 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).
#
# The Helm chart that deploys this image (with the UI) next to OpenSlice lives in
# the sibling repo org.etsi.osl.chronos.deploy.
#
# 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.

stages:
  - build
@@ -53,12 +42,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"