OhadBasan
OhadBasan

Reputation: 807

Triggering job on github pr to a specific branch

I am using the github branch source plugin: https://github.com/jenkinsci/github-branch-source-plugin to trigger jobs from github pr.

I would like jenkins trigger a build only when a pr to the master branch is made. I tried to use the branch filter plugin but it doesn't trigger at any pr. I guess it doesnt work on prs, only on direct push to branches.

is that possible?

Upvotes: 0

Views: 432

Answers (1)

Anton Yurchenko
Anton Yurchenko

Reputation: 619

this should to the trick. (there is a downside though as this condition is not on a plugin level, so the build will be triggered on other events too)

stage('build') {
  when {
    allOf {
      branch 'PR-*'
      environment name: 'CHANGE_TARGET', value: 'master'
    }
  }
  steps {
    sh 'building pr on master'
  }
}

Upvotes: 1

Related Questions