Skip to content
Snippets Groups Projects
Commit 97b2ca76 authored by Dimitrios Giannopoulos's avatar Dimitrios Giannopoulos
Browse files

made all jobs run only on certain branch push

parent 75339df9
Branches
Tags
2 merge requests!36Merging 2024Q2_RC into main, creating 2024Q2 Release,!7Resolve "Create a pipeline to build and publish the docker image in gitlab registry"
Pipeline #3755 passed with stages
in 1 minute and 54 seconds
......@@ -2,6 +2,13 @@ stages:
- java_build
- docker_build
# Define default rules as a YAML anchor
.default_rules: &default_rules
rules:
- 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"'
variables:
DEFAULT_TAG: "1.2.0-SNAPSHOT"
......@@ -20,6 +27,7 @@ deploy_jar:
image: maven:3.9.5-ibm-semeru-17-focal
script:
- mvn deploy -s ci_settings.xml -DskipTests -Dversion=$APP_VERSION
<<: *default_rules
download_jar:
stage: docker_build
......@@ -34,6 +42,7 @@ download_jar:
artifacts:
paths:
- target/
<<: *default_rules
build_image:
stage: docker_build
......@@ -47,9 +56,6 @@ build_image:
echo "Pushing Docker image with tag 'latest'"
/kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:latest"
fi
rules:
- 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"'
<<: *default_rules
needs:
- download_jar
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment