stages: - analyze - build - merge variables: TARGET_PROJECT: "mrds%2Foci-terraform%2Fmars%2Fmars-airflow" GITLAB_API_URL: "https://gitlab.sofa.dev/api/v4/projects" sonarqube_check_latest_sources: stage: analyze image: artifactory.sofa.dev/docker-remote/sonarsource/sonar-scanner-cli:latest script: - sonar-scanner -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.projectBaseDir=. -Dsonar.sources=. -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN rules: - if: '$CI_COMMIT_BRANCH == "latest"' build_airflow_from_dev_branch: stage: build when: manual script: - echo "Triggering pipeline in $TARGET_PROJECT on branch $TARGET_BRANCH..." - apt-get update && apt-get install curl -y - echo "#############################################################" - echo "" - echo -e "\e[31mContinue to https://gitlab.sofa.dev/mrds/oci-terraform/mars/mars-airflow/-/pipelines to see the build process progress, its result and to trigger deployment to DEV\e[0m" - echo "" - echo "#############################################################" - | set -e RESPONSE=$(curl --silent --show-error --fail --request POST \ --form token="$TRIGGER_TOKEN" \ --form ref="dev" \ --form "variables[COMMIT_MESSAGE]=$CI_COMMIT_MESSAGE" \ --form "variables[COMMIT_SHA]=$CI_COMMIT_SHA" \ --form "variables[MR_AUTHOR]=$GITLAB_USER_NAME" \ "$GITLAB_API_URL/$TARGET_PROJECT/trigger/pipeline") || { echo "ERROR: Failed to trigger remote pipeline!" echo "$RESPONSE" exit 1 } echo "$RESPONSE" only: - dev build_airflow_from_latest_branch: stage: build script: - echo "Triggering pipeline in $TARGET_PROJECT on branch $TARGET_BRANCH..." - apt-get update && apt-get install curl -y - echo "#############################################################" - echo "" - echo -e "\e[31mContinue to https://gitlab.sofa.dev/mrds/oci-terraform/mars/mars-airflow/-/pipelines to see the build process and its result\e[0m" - echo "" - echo "#############################################################" - | set -e RESPONSE=$(curl --silent --show-error --fail --request POST \ --form token="$TRIGGER_TOKEN" \ --form ref="main" \ --form "variables[COMMIT_MESSAGE]=$CI_COMMIT_MESSAGE" \ --form "variables[COMMIT_SHA]=$CI_COMMIT_SHA" \ --form "variables[MR_AUTHOR]=$GITLAB_USER_NAME" \ "$GITLAB_API_URL/$TARGET_PROJECT/trigger/pipeline") || { echo "ERROR: Failed to trigger remote pipeline!" echo "$RESPONSE" exit 1 } echo "$RESPONSE" only: - latest create_mr_dev_to_latest: stage: merge script: - apt-get update && apt-get install curl git sed -y - | if [ "$CI_COMMIT_BRANCH" != "dev" ]; then echo -e "\e[31mERROR: Merge requests to latest branch are only allowed from dev branch.\e[0m" exit 1 fi - bash .ci/mr_dev_to_latest.sh | tee mr_dev_to_latest.log when: manual allow_failure: false only: - dev artifacts: paths: - mr_dev_to_latest.log expire_in: 7 days