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

variables:
  APP_VERSION: "1.2.0-SNAPSHOT"

Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
# download_jar:
#   stage: prepare
#   variables:
#     LOGGING_STRATEGY: "-q"
#   image: maven:3.9.5-ibm-semeru-17-focal
#   script:
#     - echo "Maven logging strategy set to quiet. For more verbosity, change LOGGING_STRATEGY in the job configuration."
#     - mvn -s ci_settings.xml $LOGGING_STRATEGY dependency:get -Dartifact=org.etsi.osl:org.etsi.osl.tmf.api:$APP_VERSION
#     - mvn -s ci_settings.xml dependency:copy -Dartifact=org.etsi.osl:org.etsi.osl.tmf.api:$APP_VERSION -DoutputDirectory=target/
#     - mv target/org.etsi.osl.tmf.api-*.jar target/org.etsi.osl.tmf.api-${APP_VERSION}-exec.jar
#     - ls target
#   artifacts:
#     paths:
#       - target/
build_image:
  stage: build
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
    name: gcr.io/kaniko-project/executor:debug-a1af057f997316bfb1c4d2d82719d78481a02a79
    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"
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
    # - mkdir -p /kaniko/.docker
    # - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor
        --context "${CI_PROJECT_DIR}"
        --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
        --destination "${CI_REGISTRY_IMAGE}:$IMAGE_TAG"
        --verbosity=debug
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
      if [ ! -z "$ADDITIONAL_TAG" ]; then
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
        echo "Executing Kaniko build for additional tag $ADDITIONAL_TAG"
        /kaniko/executor
          --context "${CI_PROJECT_DIR}"
          --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
          --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"'
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
# deploy:
#   stage: deploy
#   image: maven:3.9.5-ibm-semeru-17-focal
#   script:
#     - mvn deploy -s ci_settings.xml -DskipTests