7

I'd like to config Jenkins that build only one branch has been pushed to github. I tried with leave blank at Branch Specifier

But after I committed/pushed all branches will be built. I just need only one branch has just been committed/pushed to be built. How can I do that? Thanks.

Inforedaster
  • 1,260
  • 1
  • 23
  • 39
Charles PHAM
  • 840
  • 3
  • 13
  • 25

1 Answers1

0

Did you consider the pipelines triggered by external hooks? If github support hooks (I don't know it) you can do something like below in post-receive hook. This will run the job only if the code was pushed to the development branch.

while read oldrev newrev ref
do
    if [[ $ref =~ .*/development$ ]];
    then
            curl -s http://jenkins:8080/job/stage/build
            echo Jenkins pipeline triggered by calling the webservice
    fi
done
h__
  • 761
  • 3
  • 12
  • 41