How to generate JIRA tickets using Jenkins and the JIRA Steps plugin?

Hey folks, I’m trying to set up JIRA ticket creation through Jenkins using the JIRA Steps plugin. I’m running into some issues though. JIRA disabled basic auth for their APIs, so I’m not sure where to get the required info now.

I’ve set up the plugin, but when I try to run my pipeline, I get an error. Here’s my current pipeline code:

node {
  stage('Create JIRA Ticket') {
    withEnv(['JIRA_SITE=MyJiraInstance']) {
      def newIssue = [
        fields: [
          project: [key: 'PRJ'],
          summary: 'Test Issue',
          issuetype: [name: 'Task']
        ]
      ]
      
      result = jiraCreateIssue issue: newIssue
      echo "Success: ${result.successful}"
      echo "Data: ${result.data}"
    }
  }
}

Any ideas on what I’m doing wrong or how to get this working? Thanks in advance for any help!

I’ve dealt with similar JIRA integration issues before, and you’re right about the basic auth changes causing headaches. Here’s what worked for me:

Instead of using basic auth, you’ll need to generate an API token from your JIRA account. Go to your JIRA profile settings, look for ‘API tokens’ or ‘Security’, and create a new token.

In Jenkins, update your JIRA site configuration. Use your email as the username and the API token as the password. Make sure you’ve got the correct JIRA URL too.

Your pipeline looks good, but you might need to add some error handling. Try wrapping your JIRA steps in a try-catch block to get more detailed error messages. Also, double-check your project key and issue type - those can sometimes cause silent failures.

If you’re still stuck, enable debug logging for the JIRA Steps plugin in Jenkins. It’ll give you more verbose output to troubleshoot with. Good luck!

From my experience, configuring Jenkins with JIRA Steps can be tricky. Have you considered using the JIRA API directly instead? It offers more flexibility and control. You’d need to set up a service account in JIRA with appropriate permissions, then use that account’s credentials in Jenkins.

For your pipeline, try using the HTTP Request plugin to make API calls. This approach bypasses some of the limitations of the JIRA Steps plugin. You’ll need to construct the JSON payload for the ticket creation and handle the response parsing yourself, but it’s more robust in the long run.

Remember to store your JIRA credentials securely in Jenkins, perhaps using the Credentials plugin. This keeps your sensitive information out of your pipeline code. Also, implement proper error handling and logging in your pipeline to make troubleshooting easier.

hey there! have u tried using the JIRA REST API instead? it’s a bit more work but gives u more control. u’ll need to create a PAT (personal access token) in JIRA and use that for auth. then u can use the HTTP Request plugin in jenkins to make API calls directly. might solve ur auth issues!