Hi I am creating different branches.I have a different setup in each Branch.
when i am merging both brnaches my gitlab-ci.yml file also merging and overwriting the changes of the target branch.
I want to exclude .gitlab-ci.yml file while merging 2 branches. is it possible? or is there any way I can make it templates?
I could think of merge strategies, e.g.
ours
. Lately I had seen that you can do that within .gitattributes for specific files in a persistent way. Though you need to do a deep dive into merge drivers, with first creating
ours
always returning
true
.
git config --global merge.ours.driver true
Then you can add a new file called .gitattributes (or modify an existing one), add and commit that then.
.gitlab-ci.yml merge=ours
This works with local merges, but also needs installment on the GitLab server, e.g. when a Merge Request should be merged.
Feature request: https://gitlab.com/gitlab-org/gitlab/issues/18830 - this holds a workaround for modifying the global .gitconfig on the server
https://stackoverflow.com/questions/42720116/gitlab-merge-behavior-keep-file-from-branch
Cheers,
Michael
Have the same gitlab-ci.yml file in all the branches and have different job with “only” tag having the branch name.
only - <branch_name>
Example:
production copy job:
stage: deploy
tags:
- production
script:
- aws s3 sync dist/ s3://prod-bucket/
only:
- production
staging copy job:
stage: deploy
tags:
- staging
script:
- aws s3 sync dist/ s3://staging-bucket/
only:
- staging
Just an example solution, haven’t tried this yet.
Gitlab guys just added docs how to setup global config value in gitlab.rb Git attributes | GitLab
Edit /etc/gitlab/gitlab.rb.
Add configuration similar to the following:
gitaly['configuration'] = {
# ...
git: {
# ...
config: [
# ...
{ key: "merge.ours.driver", value: "true" },
Original issue solved Use gitattributes custom merge driver in MRs (#18830) · Issues · GitLab.org / GitLab · GitLab