Add [ci-skip] for merge_request pipelines
Problem to solve
There are some cases where we don't want to waste build time for specific merge requests. Thus, if a MR description contains [ci skip] (or any other form, with _- or combined cases) we should be able to skip a job via only/except directives.
The same mechanism exists for regular pipelines (those not executed in a merge request context).
However, in this case too one should have control if a job is executed or NOT via only/except directives that check CI_COMMIT_MESSAGE.
Intended users
Developers.
Further details
We currently hack this functionality in an ugly as hell pre-build check that looks like this:
before_script:
# skip build if MR description has [ci-skip]
- "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12"
- $GLPT = @{ 'Private-Token' = $env:GitLab_PrivateToken }
- $GITLAB_API = 'https://git.DOMAIN.TLD/api/v4'
- $GLMR_SINGLE = "$GITLAB_API/projects/1/merge_requests/$CI_MERGE_REQUEST_IID"
- $mr = Invoke-RestMethod -headers $GLPT -uri $GLMR_SINGLE
- if ($mr.description -match '\[ci[ _-]skip\]') { exit 0 }
I find it silly to ask for information that Gitlab can offer it directly.
Proposal
One simple solution would be to expose a CI_MERGE_REQUEST_DESCRIPTION variable like we have for TITLE (currently used for WIP check).
Another solution is have new variables passed for CI:
CI_MERGE_REQUEST_SKIP*
Zero or more variables are created depending on the content of MR description:
-
[ci skip]=>CI_MERGE_REQUEST_SKIP(space or "_-" separator) -
[ci skip debug]=>CI_MERGE_REQUEST_SKIP_DEBUG -
[ci skip release]=>CI_MERGE_REQUEST_SKIP_RELEASE -
[ci skip anyalphanumstr]=>CI_MERGE_REQUEST_SKIP_ANYALPHANUMSTR -
[ci skip any alphanum str]=>CI_MERGE_REQUEST_SKIP_ANY_ALPHANUM_STR - etc
Documentation
TODO
Testing
TODO