fix(ci): build and push the image for release tags

Pushing a release tag such as 2.0.0 built no image. build-and-push ran only for the main and develop branches, and it always named the image ci-<branch>-<sha>. The helm chart on main points at service-resource-manager:2.0.0, which therefore doesn't exist.

Changes in .gitlab-ci.yml (build-and-push), matching the federation-manager fix:

  • The image is named after the git tag when the pipeline runs for a tag: ${CI_COMMIT_TAG:-ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}}. Branch builds keep their ci-… names.
  • New rule $CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/ runs the job for release tags. It sits after the SDK-trigger when: never rule, so TF-SDK consumer pipelines still skip the build.

After merging: tag the merge commit on main as 2.0.0 and push the tag. The pipeline runs the checks, then pushes labs.etsi.org:5050/oop/code/service-resource-manager:2.0.0.

Merge request reports

Loading
+3 −2
Changes for .gitlab-ci.yml: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -91,13 +91,14 @@ build-and-push:
  before_script:
    - docker info
  script:
    - export TEST_IMAGE_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
    - export IMAGE_TAG="${CI_COMMIT_TAG:-ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}}"
    - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
    - docker buildx build --provenance=false --network=host -t "$CI_REGISTRY_IMAGE:$TEST_IMAGE_TAG" --push .
    - docker buildx build --provenance=false --network=host -t "$CI_REGISTRY_IMAGE:$IMAGE_TAG" --push .
    - docker logout "$CI_REGISTRY"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "pipeline" && $SDK_PROJECT_ID == "396"'
      when: never
    - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
    - if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"'

sdk-consumer:
Loading