New Feature: Pull Request DSL

Today we are announcing the introduction of simple DSL to interface with GitHub Pull Requests. The DSL allows for the auto merge of a PR (mergePullRequest) or posting a general comment to the PR (commentPullRequest). Full Documentation can be found here.. This functionality also includes the introduction of a new plugin to the application, pipeline-github. This plugin allows for scripted pipelines (or shared libraries) to fully interface with the pull request using the pullRequest object that is only available during PR builds. This plugin also allows for the use of new build triggers for when a pull request status has changed or when a comment is made on a pull request.

Examples

Merge Pull Request on Build Success

pipeline {
  agent any

  stages {
    stage('Pull Request Build') {
      when { changeRequest() }
      steps {
        echo "<Pull Request Build Steps Here>"
      }
    }

    stage('Deploy App') {
      when { not { changeRequest() } }
      steps {
        echo "<Deploy Steps Here>"
      }
    }
  }

  post {
    success {
      mergePullRequest()
    }
  }
}
Pipeline that auto merges on success

Comment on Pull Request on Build Failure

pipeline {
  agent any

  stages {
    stage('Build Steps') {
      steps {
        echo "<Build Steps Here>"
      }
    }
  }

  post {
    failure {
      commentPullRequest("[Build Failure](${env.BUILD_URL})")
    }
  }
}
Pipeline that posts a comment with link to PR on failure

Reach Out

For any questions/concerns/feature requests, feel free to create an issue on our repository.