A much better alternative for building Jenkins jobs via the GUI is making them as Jenkins pipelines.
The result of the (below) simple demo configuration is that each time you push updates to the Git repo, a Jenkinsfile for that (changed) branch is started. In the Jenkinsfile you can output the branch name.
How? You can easily create such a configuration yourself in a few minutes. In this case I have a Jenkins server running on my local PC. So, this Jenkins server is by default not accessable for a webhook in the Git project. (Notice: you can use Webhook relay to simulate real webhooks). When the Git server can access the Jenkins server, then you should definitely use a webhook.
- Create a project and put it in a Git(lab) repo.
- Add this simple Jenkinsfile (pipeline) to your project.
.
node {
stage('Preparation') {
checkout scm
}
stage('Who am i?') {
echo "This job was triggered by a Git push to branch: ${env.BRANCH_NAME}"
}
}
- Jenkins > New Item > Multibranch pipeline. If your Jenkins server is not accessable for the Git server you can use polling. Otherwise you can setup a webhook via the Git server.

- Jenkins will now scan the Git project for branches having a 'Jenkinsfile'. For each matching branch (having a Jenkinsfile) it will automatically create a Jenkins Pipeline job. The jobs have the name of the branch. At first there will be only 1 branch, so there will be 1 job with the name 'master' created. The newly created jenkins job will execute the 'Jenkinsfile' for the 'master' branch. In the console you will see the output with the name of the branch: master.
- Create a branch and make a change to the Jenkinsfile. Push the changes to the branch.
- After waiting max 1 minute (due to the polling) the multibranch job will scan whether there are new branches with a Jenkinsfile. In this case a new jenkins job is created with the name of the branch. All jobs are visible below the Multibranch job. The job will be executed and printout the branch name.
- If you only make a change to an existing branch AND you push the change to the Git project, then within 1 minute the branches are scanned. Jenkins will see that the branch is changed and start the Jenkins pipeline job.