Commit 5e75848a authored by Avielle Wolfe's avatar Avielle Wolfe Committed by Grzegorz Bizon

Use CI_DEFAULT_BRANCH in Auto DevOps templates

We now have a CI_DEFAULT_BRANCH variable for use in our Auto DevOps
CI templates, which allows us to code logic for any default branch,
not just those named `master`.

This change was previously released with the intention that the
variable would be interpolated under the `ref` key of `only/except`,
but that didn't work so I reverted it. Now it exists under the
`variables` key, where it seems to be working.

https://gitlab.com/gitlab-org/gitlab/issues/33601
parent 8d10edca
......@@ -113,9 +113,10 @@ promoteBeta:
promoteProduction:
extends: .promote_job
stage: production
# We only allow production promotion on `master` because
# We only allow production promotion on the default branch because
# it has its own production scoped secret variables
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
script:
- bundle exec fastlane promote_beta_to_production
......@@ -10,7 +10,8 @@ docker-build-master:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
docker-build:
# Official docker image.
......@@ -24,4 +25,5 @@ docker-build:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -24,9 +24,8 @@ review:
- tags
kubernetes: active
except:
refs:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $REVIEW_DISABLED
stop_review:
......@@ -48,9 +47,8 @@ stop_review:
- tags
kubernetes: active
except:
refs:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $REVIEW_DISABLED
# Staging deploys are disabled by default since
......@@ -73,10 +71,9 @@ staging:
name: staging
url: http://$CI_PROJECT_PATH_SLUG-staging.$KUBE_INGRESS_BASE_DOMAIN
only:
refs:
- master
kubernetes: active
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $STAGING_ENABLED
# Canaries are disabled by default, but if you want them,
......@@ -98,10 +95,9 @@ canary:
url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
when: manual
only:
refs:
- master
kubernetes: active
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $CANARY_ENABLED
.production: &production_template
......@@ -126,9 +122,9 @@ canary:
production:
<<: *production_template
only:
refs:
- master
kubernetes: active
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
except:
variables:
- $STAGING_ENABLED
......@@ -141,10 +137,9 @@ production_manual:
when: manual
allow_failure: false
only:
refs:
- master
kubernetes: active
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $STAGING_ENABLED
- $CANARY_ENABLED
except:
......@@ -152,7 +147,7 @@ production_manual:
- $INCREMENTAL_ROLLOUT_ENABLED
- $INCREMENTAL_ROLLOUT_MODE
# This job implements incremental rollout on for every push to `master`.
# This job implements incremental rollout for every push to the default branch.
.rollout: &rollout_template
extends: .auto-deploy
......@@ -178,10 +173,9 @@ production_manual:
when: manual
# This selectors are backward compatible mode with $INCREMENTAL_ROLLOUT_ENABLED (before 11.4)
only:
refs:
- master
kubernetes: active
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $INCREMENTAL_ROLLOUT_MODE == "manual"
- $INCREMENTAL_ROLLOUT_ENABLED
except:
......@@ -193,10 +187,9 @@ production_manual:
when: delayed
start_in: 5 minutes
only:
refs:
- master
kubernetes: active
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
- $INCREMENTAL_ROLLOUT_MODE == "timed"
timed rollout 10%:
......
......@@ -64,7 +64,8 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
# WARNING: This template is using the `julia` images from [Docker
# Hub][3]. One can use custom Julia images and/or the official ones found
......
......@@ -6,7 +6,7 @@
# This template will build and test your projects
# * Caches downloaded dependencies and plugins between invocation.
# * Verify but don't deploy merge requests.
# * Deploy built artifacts from master branch only.
# * Deploy built artifacts from the default branch only.
variables:
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
......@@ -33,7 +33,8 @@ cache:
script:
- 'mvn $MAVEN_CLI_OPTS verify'
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
# Verify merge requests using JDK8
verify:jdk8:
......@@ -42,7 +43,7 @@ verify:jdk8:
# To deploy packages from CI, create a ci_settings.xml file
# For deploying packages to GitLab's Maven Repository: See https://docs.gitlab.com/ee/user/project/packages/maven_repository.html#creating-maven-packages-with-gitlab-cicd for more details.
# Please note: The GitLab Maven Repository is currently only available in GitLab Premium / Ultimate.
# For `master` branch run `mvn deploy` automatically.
# For the default branch run `mvn deploy` automatically.
deploy:jdk8:
stage: deploy
script:
......@@ -51,4 +52,5 @@ deploy:jdk8:
fi
- 'mvn $MAVEN_CLI_OPTS deploy -s ci_settings.xml'
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -25,7 +25,8 @@ before_script:
release:
stage: deploy
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
artifacts:
paths:
- build/release/MyProject.exe
......
......@@ -49,7 +49,8 @@ review:
only:
- branches
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
stop-review:
<<: *deploy
......@@ -66,7 +67,8 @@ stop-review:
only:
- branches
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
staging:
<<: *deploy
......@@ -78,7 +80,8 @@ staging:
name: staging
url: http://$CI_PROJECT_NAME-staging.$OPENSHIFT_DOMAIN
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
production:
<<: *deploy
......@@ -91,4 +94,5 @@ production:
name: production
url: http://$CI_PROJECT_NAME.$OPENSHIFT_DOMAIN
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -25,4 +25,5 @@ build:
- find . -maxdepth 1 -name '*.json' -print0 | xargs -t0n1 packer build
when: manual
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -12,4 +12,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -10,4 +10,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -14,4 +14,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -9,4 +9,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -12,4 +12,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -14,4 +14,5 @@ pages:
- node_modules
key: project
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -8,10 +8,12 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
test:
script:
- hugo
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -11,7 +11,8 @@ test:
- pip install hyde
- hyde gen
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
pages:
stage: deploy
......@@ -22,4 +23,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -17,7 +17,8 @@ test:
paths:
- test
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
pages:
stage: deploy
......@@ -27,4 +28,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -34,4 +34,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -9,4 +9,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -13,4 +13,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -12,7 +12,8 @@ test:
- bundle install --path vendor
- bundle exec middleman build
except:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
pages:
script:
......@@ -24,4 +25,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -9,4 +9,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -12,4 +12,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -26,4 +26,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -48,4 +48,5 @@ pages:
paths:
- public
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
......@@ -22,7 +22,8 @@ archive_project:
- xcodebuild clean archive -archivePath build/ProjectName -scheme SchemeName
- xcodebuild -exportArchive -exportFormat ipa -archivePath "build/ProjectName.xcarchive" -exportPath "build/ProjectName.ipa" -exportProvisioningProfile "ProvisioningProfileName"
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
artifacts:
paths:
- build/ProjectName.ipa
......
......@@ -53,4 +53,5 @@ apply:
- plan
when: manual
only:
- master
variables:
- $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME
Markdown is supported
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