Loading .gitlab-ci.yml +59 Changes for .gitlab-ci.yml: 59 added lines, 0 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.osom:v1.4.0 # # Chronos's 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. stages: - build - package maven_build: stage: build image: maven:3.9-eclipse-temurin-17 rules: - if: '$CI_COMMIT_TAG' script: - mvn -B -s ci_settings.xml package artifacts: paths: - target/*.jar expire_in: 1 hour docker_build_push: stage: package needs: - maven_build image: name: gcr.io/kaniko-project/executor:v1.23.2-debug entrypoint: [""] rules: - if: '$CI_COMMIT_TAG' script: - echo "Building and pushing ${CI_PROJECT_NAME}:${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 - /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 Loading
.gitlab-ci.yml +59 Changes for .gitlab-ci.yml: 59 added lines, 0 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.osom:v1.4.0 # # Chronos's 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. stages: - build - package maven_build: stage: build image: maven:3.9-eclipse-temurin-17 rules: - if: '$CI_COMMIT_TAG' script: - mvn -B -s ci_settings.xml package artifacts: paths: - target/*.jar expire_in: 1 hour docker_build_push: stage: package needs: - maven_build image: name: gcr.io/kaniko-project/executor:v1.23.2-debug entrypoint: [""] rules: - if: '$CI_COMMIT_TAG' script: - echo "Building and pushing ${CI_PROJECT_NAME}:${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 - /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