I'm trying to improve the project building script, described in YML-file, the improvement itself seems quite trivial, but the idea of accidentally ruining the auto-builds scares me a bit.
Right now there are several branches, version tags and other stuff in the project.
A development branch, not built by the runners would be of use, because copying a huge project somehow between virtual machines to test the build on different platforms is not convenient at all. So, I want to exclude from builds some "prj-dev" branch.
And there we have:
stages:
- build
- linuxbuild
job:
tags:
- win2008build
stage: build
script:
# something complex
job1:
tags:
- linux
stage: linuxbuild
script:
# something else complex
I googled and found a solution like:
stages:
- build
- linuxbuild
job:
tags:
- win2008build
branches:
except:
- *dev-only
But it seems that our pipelines are quite different, the tags are not git tags, they are pipeline tags. So, I'm considering rather to use a config like:
stages:
- build
- linuxbuild
job:
tags:
- win2008build
except:
branches:
- *dev-only
...which would mean "build as usual, but not my branch". There are complications in trying it both ways, I'm pretty sure someone should know the recipe for sure.
So, if you please, -- how do I exclude my dev branch without changing the pipelines, config only? Is it possible at all?
For more information on managing branches using the GitLab UI, see: 1 Default branches: When you create a new project, GitLab creates a default branch for the repository. You can change this setting at the project, subgroup, group, or instance level. 2 Create a branch 3 Protected branches 4 Delete merged branches 5 Branch filter search box
In include sections in your .gitlab-ci.yml file, you can use: In GitLab 14.2 and later, the $CI_COMMIT_REF_NAME predefined variable .
When you use the include keyword, you can override the included configuration values to adapt them to your pipeline requirements. The following example shows an include file that is customized in the .gitlab-ci.yml file. Specific YAML-defined variables and details of the production job are overridden.
Instead of 'except', you can use 'only' to specify one branch which should be considered for builds exclusively. @Thomas How does this work in version 13 of GitLab? I would like to build for all tags. Except the master branch.
All you need to do is use except
in the gitlab-ci.yml
file and add your branches directly below like this:
mybuild:
stage: test
image: somedockerimage
script:
- some script running
except:
- branch-name
This is working on my project without problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With