Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Jira tickets from Jenkins workflow (jenkinsfile)

How can I update a jira issue from within a Jenkinsfile (jenkins-worflow/pipeline)? Is there a way I could use the Jira Issue Updater plugin as a step in the Jenkinsfile?

I know I could use the Jira RestAPI, but I'm trying to figure out if I can re-use the functionality provided by the jira-updater-issue.

What I'm looking for is a something similar to the example below calling Junit archiver, and atifact archiver, but calling jira updater.

    node {
      git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
      def mvnHome = tool 'M3'
      sh "${mvnHome}/bin/mvn -B -Dmaven.test.failure.ignore verify"
      step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
      step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
    }
like image 997
portenez Avatar asked Feb 08 '23 20:02

portenez


1 Answers

The Jira Plugin is compatible with Pipeline.

This should work:

step([$class: 'hudson.plugins.jira.JiraIssueUpdater', 
    issueSelector: [$class: 'hudson.plugins.jira.selector.DefaultIssueSelector'], 
    scm: [$class: 'GitSCM', branches: [[name: '*/master']], 
        userRemoteConfigs: [[url: 'https://github.com/jglick/simple-maven-project-with-tests.git']]]]) 

You can get a full reference in the built-in Pipeline Snippet Generator.

like image 149
amuniz Avatar answered Feb 12 '23 09:02

amuniz