I'm new to multi-branch pipeline concept and trying to implement in our project where we are running our jenkins builds inside docker containers.
We have a requirement where all build against "develop" branch should be doing build and docker image creation. Where as the rest created "feature/hot-fix" branches has to do only build.
I wrote a Jenkinfile file in a following way
node {
checkout scm
if (env.BRANCH_NAME == 'develop') {
stage ('Stage for develop') {
echo "Build,create an docker-image"
}
}
else if (env.BRANCH_NAME == 'feature_branch') {
stage ('Stage for feature branch') {
echo "only build"
}
}
else {
echo "Branch branch not found"
}
The problem here is we are hard-coding the feature branch names and this could be a problem if someone creates a branch with different names and Jenkinsfile will fail to identify it.
I'm trying to write in such a way that Jenkinsfile has to identify the newly created branch automatically and should run a build against it.
Any help would be appreciated.