Reputation: 1287
Our feature branches are based off of "Dev" branch. the Dev branch is Deployed to development Environment on a daily basis based on our instructions defined in .gitlab-ci.yml
on dev branch.
When a feature branch is created and commits were made, they are being deployed as feature branch .gitlab-ci.yml
is same as on Dev branch. if we disable the deploy step on feature branch and forget to uncomment it during a merge request back to dev branch, dev branch will have the .gitlab-ci.yml
file overwritten by feature branch.
Is there away to keep Dev .gitlab-ci.yml
untouched though merge requests from any feature branches?
I found .gitattributes
may help but cannot find a starting point on how to define and use it.
Upvotes: 0
Views: 1272
Reputation: 1287
I found the following works in the deploy stage of the CI.yml file
deploy:
stage: deploy
only:
- dev
- master
script:
- dotnet build -c Release
- dotnet publish -c Release
So the pipelines only run when something is merged on to Master or dev branches. This sounded simpler.
Upvotes: 0
Reputation: 5154
This is an extremely simplified example how you could define two seperate deploy steps in your .gitlab-ci.yml
with rules. It is based on the assumption that you prefix your feature branches e.g. with feature
.
stages:
- deploy
deploy:feature:
stage: deploy
script:
- echo "deploy feature branch"
rules:
- if: '$CI_COMMIT_BRANCH =~ /^feature/'
deploy:dev:
stage: deploy
script:
- echo "deploy to development"
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
Upvotes: 1