embeddedartistry/jenkins-pipeline-lib

Add function to file issue on build failure

phillipjohnston opened this issue · 1 comments

https://wiki.jenkins.io/display/JENKINS/GitHub+Issues+Plugin

script {
    properties([[$class: 'GithubProjectProperty',
                projectUrlStr: '<GitHub repo URL>']])
}


step([$class: 'GitHubIssueNotifier',
      issueAppend: true,
      issueLabel: '',
      issueTitle: '$JOB_NAME $BUILD_DISPLAY_NAME failed'])

You can modify the global config using a system groovy script, i.e. add a init.groovy to the JENKINS_HOME dir.

import org.jenkinsci.plugins.githubissues.GitHubIssueNotifier
def descriptor = Jenkins.instance.getDescriptorByType(GitHubIssueNotifier.DescriptorImpl)
descriptor.issueTitle = 'ISSUE TITLE TEMPLATE`
descriptor.issueBody = 'ISSUE BODY TEMPLATE`
descriptor.issueLabel = 'LABELA LABELB`
descriptor.save()

In the templates you can use all available tokens using ${TOKEN} notation. To see all available tokens, click the help button on the right of the Content Token Reference label in the GitHub Issues section of the global configuration UI.
To configure the global GitHub config and the credential config, see the init.groovy example in the rep