0

I am building a declarative pipeline Jenkinsfile for semantic branching. It has the format:

pipeline {
  stages {
    stage('develop branch build') {
      when {
        branch 'develop'
      }

      // build and deploy to QA environment
    }

    stage('release branch build') {
      when {
        branch 'release'
      }

      // build and deploy to live/preproduction environment
    }
  }
}

I would like an additional stage to run upon a Bitbucket pull request. It would do a particular PR test and deploy task, and pass or fail the pipeline accordingly.

How might I enhance this script to do that?

funkybro
  • 8,432
  • 6
  • 39
  • 52
  • You could block off the stage with an input parameter boolean that is set to `true` in the webhook from the Bitbucket PR. Not sure if that is best practices or not, but it works. – Matthew Schuchard Jul 25 '19 at 13:30
  • @funkybro if you install the Bitbucket source plugin: https://stackoverflow.com/questions/60711551/jenkins-pipeline-determine-if-a-branch-is-for-bitbucket-pull-request – David Masters Mar 16 '20 at 22:22

1 Answers1

1

I use the generic webhook plugin. This work pretty nice with bitbucket.

Holleoman
  • 261
  • 1
  • 7