Skip to content
.gitlab-ci.yml 1.62 KiB
Newer Older
  - java_build
  - docker_build
  DEFAULT_TAG: "1.2.0-SNAPSHOT"

before_script:
  - |
    if [ "$CI_COMMIT_REF_NAME" = "main" ] && [ -n "$CI_COMMIT_TAG" ]; then
      export APP_VERSION=$CI_COMMIT_TAG
    elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then
      export APP_VERSION="develop"
    else
      export APP_VERSION=$DEFAULT_TAG
    fi
deploy_jar:
  stage: java_build
  image: maven:3.9.5-ibm-semeru-17-focal
  script:
    - mvn deploy -s ci_settings.xml -DskipTests -Dversion=$APP_VERSION
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
download_jar:
  stage: docker_build
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
  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
  artifacts:
    paths:
      - target/
build_image:
  stage: docker_build
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
Dimitrios Giannopoulos's avatar
Dimitrios Giannopoulos committed
  script:
    - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:$APP_VERSION"
    - if: '$CI_COMMIT_REF_NAME == "main"'
    - if: '$CI_COMMIT_REF_NAME == "develop"'
    - if: '$CI_COMMIT_REF_NAME == "12-create-a-pipeline-to-build-and-publish-the-docker-image-in-gitlab-registry"'
    - download_jar