I am trying to set up Jenkins with a Git project so that:
It will build from branches matching a pattern (origin/master, origin/feature/*, origin/hotfix/*, etc.) whenever changes are pushed to the central repository
Developers and testers can trigger a build for any revision they want, specified as a build parameter that is a tag name, branch name or commit hash. The job has other parameters and we will occasionally want to create builds with something other than the default values.
I have got 1. working correctly by setting up a post-receive script on the Git server and adding multiple branch specifiers in Jenkins.
In order to also do 2., I added an extra build parameter GitRef
and then added an extra branch specifier with $GitRef
. Manually starting a build would then just keep building from the same commit/branch every time, whatever the parameter was set to. If I removed all the other branch specifiers, the manual builds would work as expected. But then the hook-triggered builds would only build from origin/master (the default value of $GitRef
).
Is what I am trying to achieve even possible without creating a two jobs for every project? If so, what do I need to do to get it working?