Skip to content
.gitlab-ci.yml 1.59 KiB
Newer Older
  - build
  - deploy

download_jar:
  stage: prepare
  image: maven:3.9.5-ibm-semeru-17-focal
  script:
    - mvn --settings ci_settings.xml dependency:get -Dartifact=org.etsi.osl.tmf.api:org.etsi.osl.tmf.api:1.2.0-SNAPSHOT -Ddest=target/
  artifacts:
    paths:
      - target/org.etsi.osl.tmf.api-1.2.0-SNAPSHOT-exec.jar
      
build_image:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:v1.14.0-debug
    entrypoint: [""]
  before_script:
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
    - |
      if [ "$CI_COMMIT_REF_NAME" = "12-create-a-pipeline-to-build-and-publish-the-docker-image-in-gitlab-registry" ]; then
        export IMAGE_TAG=$(echo $CI_COMMIT_REF_NAME | tr -cd '[:alnum:]._-') # $CI_COMMIT_TAG
        export ADDITIONAL_TAG="latest"
      elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then
        export IMAGE_TAG="develop"
      fi
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
    - echo "Building Docker image with tag $IMAGE_TAG"
    - /kaniko/executor
        --context "${CI_PROJECT_DIR}"
        --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
        --destination "${CI_REGISTRY_IMAGE}:$IMAGE_TAG"
        --verbosity=debug
    - |
      if [ ! -z "$ADDITIONAL_TAG" ]; then
        /kaniko/executor
          --context "${CI_PROJECT_DIR}"
          --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
          --destination "${CI_REGISTRY_IMAGE}:$ADDITIONAL_TAG"
      fi
  rules:
    - if: '$CI_COMMIT_REF_NAME == "12-create-a-pipeline-to-build-and-publish-the-docker-image-in-gitlab-registry" || $CI_COMMIT_REF_NAME == "develop"'

deploy:
  stage: deploy
  image: maven:3.9.5-ibm-semeru-17-focal
  script:
    - mvn deploy -s ci_settings.xml -DskipTests