I am doing code review with gerritcodereview and I need to create a jenkins pipeline for CI, CD. I am using the events triggered by gerrit trigger plugin.
I want to obtain this:
PastchSet Created
- build start on refs/changes/**/**/** branch
- report results to gerrit for code review
Change Merged(into develop) or Ref Updated(develop)
- build start on origin/develop branch
- deploy code to internal server
Ref Updated(master)
- build start on origin/master branch
- deploy code to external server
Questions for which I didn't find good answers:
- do I need to use a simple pipeline or multibranch pipeline?
- how do I start the build on the correct branch?
- how can I checkout the correct branch using a Jenkinsfile instead of using the configuration page?
You should create multibranch pipeline, and write your declarative/scripted pipeline in Jenkinsfile
example pipeline
stage build&test will run for any change in changeRequest, any new change, or patchset will trigger this stage stage deploy will be triggered for any change merged to develop. You could have multiple stages for one branch, they will be executed in sequence