I would like to checkout to dev
branch in a merge request pipeline that is opened for merging to dev
with some other branch. I am going to check somethings in this job and then continue with some other jobs depending on the success of this one. Is it possible to do such thing or do I always have to work with the branch the pipeline triggered at?
I add the related part of the gitlab configuration
variables:
GIT_STRATEGY: clone
checksomething:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "dev"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
environment:
name: development
before_script:
- git checkout dev
script:
- !reference [.check-something-on-dev]
But I have this error:
$ git checkout dev
error: pathspec 'dev' did not match any file(s) known to git```
Actually it was this easy:
before_script:
- git fetch origin dev
- git checkout dev
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