Question: Is there any way to get the name of the branch that is checkout by the Pipeline in a jenkinsfile?
NOTE: I am not in a Multibranch Pipeline!
In my pipeline im using
checkout([$class: 'GitSCM', userRemoteConfigs: [[url:'https://github.com/repo', credentialsId: 'xxxx',name: '1234']]]) where name is the commit ID. I need to verify that this commit id is from the branch that a user has specified as parameter (user specifies both branch name and commit id and I need to check if there is no error before building the project).
Why is the branch name not exposed in Pipeline but only in Multibranch Pipeline? Doesn't make sense to me.
There are three reasons why I don't want to convert to the multi branch pipeline:
- I am using another plugin Build Blocker Plugin in my pipeline that doesn't seem available in the multibranch pipeline.
- I have a parameterized pipeline, I don't see that option in the multibranch pipeline.
- A lot of time has gone into this pipeline, I simply don't want to set up this project again from scratch just for this branch name feature.
I have printed out all environment variables, branch name is not among them.
Thanks for the help!
