Search code examples
phpantjenkinsphpdoc

Jenkins - Execute ant-target only if git-branch is master?


I have a jenkins-project which is built via ant (and build.xml). In the build.xml i have specified phpDoc but i only want to execute the ant-target phpdoc if the pushed branch is the master-branch. Is this possible?


Solution

  • Yes it is possible. There are a few options depend on what SCM you use.

    E.g for git, install git plugin Next create new job in Jenkins, In SCM section select git, set proper git repository, and in Branches to build set your master branch e.g */master

    Next you need to specify build trigger. One approach is to setup proper git hook, or pull request builder. Another is to setup Poll SCM option. The second will cause that Jenkins will check your SCM every X minutes (depend on cofiguration).