How to integrate Jenkins pipeline with JIRA REST API calls

I’m working on a Jenkins pipeline and need to connect it with JIRA to perform custom operations. Specifically, I want to fetch version information from JIRA and also create new tickets programmatically.

The existing JIRA plugins have limited functionality and don’t cover my use case. I’m wondering if there’s a way to make direct REST API calls to JIRA from inside my pipeline script. Is it possible to leverage the JIRA authentication credentials that are already configured in Jenkins for these API requests?

Has anyone successfully implemented custom JIRA operations in their Jenkins pipeline using the REST API approach?

I’ve been doing this for a year now in our CI/CD pipeline. Skip the plugins and just use the built-in sh or bat step with curl commands. Way cleaner.

API tokens are your friend - much safer than basic auth. Stick your JIRA token in Jenkins credentials, then grab it with environment { JIRA_TOKEN = credentials('jira-api-token') }.

For version info, hit /rest/api/2/project/{projectKey}/versions. Creating tickets? POST to /rest/api/2/issue/. Don’t forget Content-Type: application/json and escape your JSON properly in the curl command.

Parse responses with grep or jq if it’s on your Jenkins agents.

Been wrestling with this exact scenario recently. HTTPBuilder plugin worked great for my setup - handles JSON parsing automatically without extra tools. Pull JIRA credentials using the credentials binding plugin and build your requests programmatically. One gotcha I hit - JIRA’s REST API gets picky about field validation when creating issues. Include all required fields for your project’s issue type or you’ll get cryptic 400 errors. The /rest/api/2/issue/createmeta endpoint is a lifesaver for finding what fields you actually need. For auth, personal access tokens beat username/password every time. Just set the Authorization header as Bearer {token} instead of basic auth when using tokens.

totally agree! the httpRequest plugin is the way to go. just make sure to grab your Jira creds from the Jenkins credential store and set 'em in the headers. use withCredentials([usernamePassword(credentialsId: 'jira-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) for basic auth. it’s super reliable for custom calls!