### Get Jira Project Components with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_components.md This example demonstrates how to override the default JIRA_SITE using `withEnv`. This is useful when a specific JIRA site needs to be targeted or when no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def components = jiraGetProjectComponents idOrKey: 'TEST' echo components.data.toString() } } } ``` -------------------------------- ### Get Issue Watches with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/watcher/jira_get_issue_watches.md This example shows how to override the default JIRA_SITE using `withEnv` for specific executions. Ensure the `JIRA_SITE` environment variable is set correctly. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def watches = jiraGetIssueWatches idOrKey: 'TEST-1' echo watches.data.toString() } } } ``` -------------------------------- ### Get Project Statuses with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_statuses.md This example shows how to override the default JIRA_SITE environment variable using `withEnv` for specific JIRA connections. The retrieved statuses are then echoed. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def statuses = jiraGetProjectStatuses idOrKey: 'TEST' echo statuses.data.toString() } } } ``` -------------------------------- ### Manual Installation from Source Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Instructions for manually installing the JIRA Pipeline Steps plugin by cloning the repository and building the HPI file. ```bash git clone https://github.com/jenkinsci/jira-steps-plugin.git cd jira-steps-plugin mvn package # Deploy jira-steps.hpi from target/ folder via Jenkins Advanced Installation ``` -------------------------------- ### Get All Jira Projects with Specific Site using withEnv Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_projects.md This example demonstrates how to override the default JIRA site using the `withEnv` directive. This is useful when you need to target a specific JIRA instance or when no global site is configured. The fetched project data is available in `projects.data`. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def projects = jiraGetProjects() echo projects.data.toString() } } } ``` -------------------------------- ### Complete Release Pipeline Example Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt An end-to-end example demonstrating a release workflow in Jenkins using Jira Steps Plugin. It includes creating issues, versions, editing issues, transitioning issues, and adding comments, with comprehensive error handling. ```groovy node { stage('Release Workflow') { def issueKey try { // Create release review issue def issue = [fields: [ project: [key: 'PROJ'], summary: "Release ${env.RELEASE_VERSION} Review", description: "Review changes for release ${env.RELEASE_VERSION}", issuetype: [name: 'Task'] ]] def newIssue = jiraNewIssue issue: issue, site: 'PROD_JIRA' issueKey = newIssue.data.key echo "Created release issue: ${issueKey}" // Create fix version def version = jiraNewVersion version: [ name: env.RELEASE_VERSION, description: "Release ${env.RELEASE_VERSION}", project: 'PROJ' ], site: 'PROD_JIRA' // Tag issue with fix version def updateIssue = [fields: [fixVersions: [version.data]]] jiraEditIssue idOrKey: issueKey, issue: updateIssue, site: 'PROD_JIRA' // Perform release steps here... sh './release.sh' // Close the issue on success (transition ID 31 = "Done" - varies by workflow) jiraTransitionIssue idOrKey: issueKey, input: [transition: [id: '31']], site: 'PROD_JIRA' jiraAddComment idOrKey: issueKey, input: [body: "Release ${env.RELEASE_VERSION} completed successfully!\nBuild: ${BUILD_URL}"], site: 'PROD_JIRA' } catch (error) { // Comment failure details on the issue if (issueKey) { jiraAddComment idOrKey: issueKey, input: [body: "Release FAILED!\nBuild: ${BUILD_URL}\nError: ${error.message}"], site: 'PROD_JIRA' } currentBuild.result = 'FAILURE' throw error } } } ``` -------------------------------- ### Get Issue Link with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_issuelink.md This example demonstrates how to override the default JIRA site using the `withEnv` directive. This is useful when you need to connect to a different JIRA instance or when no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def issueLink = jiraGetIssueLink id: '10000' echo issueLink.data.toString() } } } ``` -------------------------------- ### Get Jira Issue Transitions with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_issue_transitions.md This example shows how to override the default JIRA_SITE using `withEnv` for specific executions. It's useful when you need to target a different Jira instance or when no global site is set. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def transitions = jiraGetIssueTransitions idOrKey: 'TEST-1' echo transitions.data.toString() } } } ``` -------------------------------- ### Get Jira Project Info Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project.md This example shows how to override the default JIRA_SITE using `withEnv` for specific JIRA instances. It requires the project ID or key. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def project = jiraGetProject idOrKey: 'TEST' echo project.data.toString() } } } ``` -------------------------------- ### Get Jira Issue Remote Link with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_remote_issuelink.md This example demonstrates how to override the default JIRA_SITE using the `withEnv` directive. This is useful when a global site is not configured or needs to be temporarily changed. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def issueLink = jiraGetIssueRemoteLink idOrKey: 'TEST-27', linkId: '10000' echo issueLink.data.toString() } } } ``` -------------------------------- ### Get Jira Component with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_get_component.md This example shows how to override the default JIRA_SITE using the withEnv directive. This is useful when you need to target a specific JIRA instance or when no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def component = jiraGetComponent id: '10024' echo component.data.toString() } } } ``` -------------------------------- ### Configure JIRA Sites with Configuration as Code Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Example YAML configuration for setting up JIRA sites using Jenkins Configuration as Code (CasC). Supports both Basic and OAuth authentication. ```yaml unclassified: jiraStepsConfig: sites: - name: 'PROD_JIRA' url: 'https://jira.example.com' timeout: 10000 readTimeout: 10000 loginType: 'BASIC' userName: 'jenkins-user' password: 'secret-password' - name: 'CLOUD_JIRA' url: 'https://company.atlassian.net' timeout: 10000 readTimeout: 10000 loginType: 'OAUTH' consumerKey: 'my-consumer-key' privateKey: 'my-private-key' secret: 'oauth-secret' token: 'access-token' ``` -------------------------------- ### Get Jira Project Versions with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_versions.md This example demonstrates how to override the default JIRA_SITE environment variable using `withEnv`. This is useful when you need to specify a different Jira instance or if no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def versions = jiraGetProjectVersions idOrKey: 'TEST' echo versions.data.toString() } } } ``` -------------------------------- ### Get Jira Issue Remote Links with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_remote_issuelinks.md This example demonstrates how to override the default JIRA_SITE using `withEnv` for specific JIRA instances. This is useful when working with multiple Jira sites or when a global site is not set. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def issueLink = jiraGetIssueRemoteLinks idOrKey: 'TEST-27', globalId: '10000' echo issueLink.data.toString() } } } ``` -------------------------------- ### Get Jira Issue Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_issue.md This example shows how to override the default JIRA_SITE using the withEnv directive, useful when no global site is configured or a specific one is needed. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def issue = jiraGetIssue idOrKey: 'TEST-1' echo issue.data.toString() } } } ``` -------------------------------- ### Get Jira Project Components with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_components.md Use this snippet to fetch project components using the default JIRA_SITE environment variable. Ensure the JIRA_SITE is configured globally. ```groovy node { stage('JIRA') { def components = jiraGetProjectComponents idOrKey: 'TEST' echo components.data.toString() } } ``` -------------------------------- ### Create Jira Component with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_new_component.md This example shows how to create a Jira component while overriding the default JIRA_SITE using the `withEnv` directive. This is useful when a specific site configuration is needed or no global site is set. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def testComponent = [ name: 'test-component', description: 'desc', project: 'TEST' ] jiraNewComponent component: testComponent } } } ``` -------------------------------- ### Get JIRA Fields Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_fields.md This example demonstrates how to override the default JIRA_SITE using withEnv. This is useful when you need to target a different JIRA instance or when no global site is set. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def fields = jiraGetFields idOrKey: 'TEST-1' echo fields.data.toString() } } } ``` -------------------------------- ### Download Attachment with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/attachment/jira_download_attachment.md This example demonstrates downloading an attachment while overriding the default JIRA_SITE using the `withEnv` directive. This is useful when you need to specify a different JIRA site for a particular stage or job. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def attachment = jiraDownloadAttachment id: '1000', file: 'test.txt', override: true echo attachment.data.toString() } } } ``` -------------------------------- ### Get JIRA Version Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_get_version.md This example shows how to override the default JIRA site using `withEnv` for specific stages or when no global site is configured. Ensure the `JIRA_SITE` environment variable is set correctly. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def version = jiraGetVersion id: '10000' echo version.data.toString() } } } ``` -------------------------------- ### Handle Jira Step Response and Errors Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/getting-started/config/common.md This example demonstrates how to retrieve and display the response details from a Jira step, including success status, HTTP code, error messages, and data. It also shows how to use a try-catch block to handle potential exceptions during step execution. ```groovy def response = jiraGetComponent id: 10000 echo response.successful echo response.code echo response.error echo response.data.toString() try { jiraGetComponent id: 10000 } catch (error) { echo error } ``` -------------------------------- ### Transition Jira Issue with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_transition_issue.md This example shows how to override the default JIRA_SITE using `withEnv` for a specific stage. This is useful when you need to use a different Jira instance or if no global JIRA_SITE is set. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def transitionInput = [ transition: [ id: '5' ] ] jiraTransitionIssue idOrKey: 'TEST-1', input: transitionInput } } } ``` -------------------------------- ### Get Attachment Info Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/attachment/jira_get_attachment_info.md This example shows how to override the default JIRA_SITE using `withEnv` to specify a different site. This is useful when the default environment variable is not set or needs to be changed. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def attachment = jiraGetAttachmentInfo id: '1000' echo attachment.data.toString() } } } ``` -------------------------------- ### Get Project Statuses with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_statuses.md Use this snippet to get project statuses when the JIRA_SITE environment variable is set globally. The output is echoed to the console. ```groovy node { stage('JIRA') { def statuses = jiraGetProjectStatuses idOrKey: 'TEST' echo statuses.data.toString() } } ``` -------------------------------- ### Get Jira Comment with Specific Site via withEnv Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/comment/jira_get_comment.md This example demonstrates how to override the default Jira site using the `withEnv` directive. This is useful when you need to target a specific Jira instance or if no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def comment = jiraGetComment idOrKey: 'TEST-1', commentId: '10004' echo comment.data.toString() } } } ``` -------------------------------- ### Get Jira Project Versions with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_versions.md Use this snippet to fetch project versions using the default JIRA_SITE environment variable. Ensure the JIRA_SITE variable is configured globally. ```groovy node { stage('JIRA') { def versions = jiraGetProjectVersions idOrKey: 'TEST' echo versions.data.toString() } } ``` -------------------------------- ### Create Remote Link with Specific Site using withEnv Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_new_remote_issuelink.md This example demonstrates how to create a remote link to a Jira issue while overriding the default JIRA_SITE using the `withEnv` directive. This is useful when you need to target a specific Jira instance or when no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def remoteLink = [globalId: "system=http://www.mycompany.com/support&id=1", application: [type: "com.acme.tracker", name: "My Acme Tracker"], relationship: "causes", object: [url: "http://www.mycompany.com/support?id=1", title: "MYTEST-111"]] def issueLink = jiraNewIssueRemoteLink idOrKey: 'TEST-27', remoteLink: remoteLink echo issueLink.data.toString() } } } ``` -------------------------------- ### Get Jira Component with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_get_component.md Use this snippet to query a JIRA component using the default JIRA_SITE environment variable. Ensure the JIRA_SITE is configured globally. ```groovy node { stage('JIRA') { def component = jiraGetComponent id: '10024' echo component.data.toString() } } ``` -------------------------------- ### Get Issue Watches Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/watcher/jira_get_issue_watches.md Use this snippet when no environment variables are configured for JIRA_SITE. The `site` parameter must be explicitly provided. ```groovy def watches = jiraGetIssueWatches idOrKey: 'TEST-1', site: 'LOCAL' echo watches.data.toString() ``` -------------------------------- ### Get Project Statuses Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_statuses.md Use this snippet when no environment variables are configured for JIRA. The `site` parameter must be explicitly provided. The statuses are then echoed. ```groovy def statuses = jiraGetProjectStatuses idOrKey: 'TEST', site: 'LOCAL' echo statuses.data.toString() ``` -------------------------------- ### Get Jira Server Info with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/admin/jira_server_info.md Retrieves Jira server information using the default JIRA_SITE environment variable. Ensure the JIRA_SITE environment variable is configured globally. ```groovy node { stage('JIRA') { def serverInfo = jiraGetServerInfo() echo serverInfo.data.toString() } } ``` -------------------------------- ### Get Component Issue Count with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_get_component_issue_count.md This example shows how to override the default JIRA_SITE environment variable using `withEnv` for a specific stage or block. This is useful when you need to target a different Jira instance or when a global site is not configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def count = jiraGetComponentIssueCount id: '10024' echo count.data.toString() } } } ``` -------------------------------- ### Create New Jira Version with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_new_version.md This example demonstrates how to override the default JIRA_SITE environment variable using `withEnv` for a specific execution. This is useful when working with multiple Jira instances or when a global site is not configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def testVersion = [ name: 'test-version', archived: true, released: true, description: 'desc', project: 'TEST' ] jiraNewVersion version: testVersion } } } ``` -------------------------------- ### Get Jira Project Info with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project.md Use this snippet to retrieve project details when a global JIRA_SITE environment variable is configured. The project ID or key is required. ```groovy node { stage('JIRA') { def project = jiraGetProject idOrKey: 'TEST' echo project.data.toString() } } ``` -------------------------------- ### Get Jira Issue Transitions with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_issue_transitions.md Use this snippet to retrieve issue transitions when a default JIRA_SITE is configured globally. The response data can be printed directly. ```groovy node { stage('JIRA') { def transitions = jiraGetIssueTransitions idOrKey: 'TEST-1' echo transitions.data.toString() } } ``` -------------------------------- ### Get All Jira Projects with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_projects.md Use this snippet to fetch all projects from your JIRA site using the default site configured in global environment variables. The response data can be accessed via `projects.data`. ```groovy node { stage('JIRA') { def projects = jiraGetProjects() echo projects.data.toString() } } ``` -------------------------------- ### Get Jira Issue with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_issue.md Use this snippet to retrieve a JIRA issue using the default JIRA_SITE environment variable. It demonstrates how to pass query parameters. ```groovy node { stage('JIRA') { def queryParams = [expand: 'changelog'] def issue = jiraGetIssue idOrKey: 'TEST-1', queryParams: queryParams echo issue.data.toString() } } ``` -------------------------------- ### Get Jira Project Information Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Retrieves detailed information about a specific JIRA project using its ID or key. The response contains project details like name, key, lead, and description. ```groovy node { stage('Get Project Info') { def response = jiraGetProject idOrKey: 'PROJ', site: 'PROD_JIRA' def project = response.data echo "Project: ${project.name}" echo "Key: ${project.key}" echo "Lead: ${project.lead.displayName}" echo "Description: ${project.description}" } } ``` -------------------------------- ### Get Comments with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/comment/jira_get_comments.md Use this snippet to fetch comments for a Jira issue using the default JIRA_SITE environment variable. Ensure the JIRA_SITE is configured globally. ```groovy node { stage('JIRA') { def comments = jiraGetComments idOrKey: 'TEST-1' echo comments.data.toString() } } ``` -------------------------------- ### Get Jira Project Info Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project.md Retrieve project details by explicitly providing the JIRA site and project ID or key. This is useful when no environment variables are set. ```groovy def project = jiraGetProject idOrKey: 'TEST', site: 'LOCAL' echo project.data.toString() ``` -------------------------------- ### Get Jira Issue Transitions Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_issue_transitions.md Use this snippet when you need to specify the Jira site directly within the step, without relying on environment variables. This is suitable for ad-hoc calls or when environment configuration is not feasible. ```groovy def transitions = jiraGetIssueTransitions idOrKey: 'TEST-1', site: 'LOCAL' echo transitions.data.toString() ``` -------------------------------- ### Get Issue Link with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_issuelink.md Use this snippet to retrieve an issue link using the default JIRA site configured in environment variables. The output of the step is echoed to the console. ```groovy node { stage('JIRA') { def issueLink = jiraGetIssueLink id: '10000' echo issueLink.data.toString() } } ``` -------------------------------- ### Get JIRA Version Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_get_version.md Retrieve a JIRA version by explicitly providing the `site` and `failOnError` parameters. This is useful when environment variables are not available or need to be bypassed. ```groovy def version = jiraGetVersion id: '10000', site: 'LOCAL', failOnError: false echo version.data.toString() ``` -------------------------------- ### Get Jira Server Information Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Retrieves information about the JIRA server, including its version, build number, server time, and base URL. Useful for verifying connectivity and JIRA version. ```groovy node { stage('Check JIRA Server') { def response = jiraGetServerInfo site: 'PROD_JIRA' echo "JIRA Version: ${response.data.version}" echo "Build Number: ${response.data.buildNumber}" echo "Server Time: ${response.data.serverTime}" echo "Base URL: ${response.data.baseUrl}" } } ``` -------------------------------- ### Get JIRA Version with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_get_version.md Use this snippet to retrieve a JIRA version using the default site configured in global environment variables. The response data can be accessed via `response.data`. ```groovy node { stage('JIRA') { def version = jiraGetVersion id: '10000' echo version.data.toString() } } ``` -------------------------------- ### Get Issue Link Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_issuelink.md Use this snippet when you need to specify the JIRA site and other parameters directly within the step, without relying on environment variables. The `failOnError` parameter is also set to `false`. ```groovy def issueLink = jiraGetIssueLink id: '10000', site: 'LOCAL', failOnError: false echo issueLink.data.toString() ``` -------------------------------- ### Notify Jira Issue with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_notify_issue.md This example demonstrates how to override the default JIRA_SITE using `withEnv` for specific notifications. This is useful when you need to target a different Jira instance or when no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def notify = [ subject: 'Update about TEST-01', textBody: 'Just wanted to update about this issue...', htmlBody: 'Just wanted to update about this issue...', to: [ reporter: true, assignee: true, watchers: false, voters: false, users: [{ name: 'rao' }, { name: 'naresh' }] ] ] jiraNotifyIssue idOrKey: 'TEST-1', notify: notify } } } ``` -------------------------------- ### Get All Jira Projects without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_projects.md This snippet shows how to call `jiraGetProjects` by explicitly providing the site name as a parameter. This method is suitable when environment variables are not set up or when you need a quick, direct way to specify the JIRA site. The project data is accessible through `projects.data`. ```groovy def projects = jiraGetProjects(), site: 'LOCAL' echo projects.data.toString() ``` -------------------------------- ### Create New Jira Issues Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_new_issues.md This example demonstrates how to override the default JIRA_SITE environment variable using `withEnv` for creating Jira issues. This is useful when a specific JIRA site needs to be targeted. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { # Look at IssueInput class for more information. def testIssue1 = [fields: [ project: [id: '10000'], summary: 'New JIRA Created from Jenkins.', description: 'New JIRA Created from Jenkins.', issuetype: [id: '3']]] def testIssue2 = [fields: [ project: [id: '10000'], summary: 'New JIRA Created from Jenkins.', description: 'New JIRA Created from Jenkins.', issuetype: [id: '3']]] def testIssues = [issueUpdates: [testIssue1, testIssue2]] response = jiraNewIssues issues: testIssues echo response.successful.toString() echo response.data.toString() } } } ``` -------------------------------- ### Get Jira Server Info with Overridden Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/admin/jira_server_info.md Retrieves Jira server information by overriding the default JIRA_SITE environment variable using withEnv. This is useful when you need to specify a different Jira instance or if no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def serverInfo = jiraGetServerInfo() echo serverInfo.data.toString() } } } ``` -------------------------------- ### Get Jira Project Versions Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_versions.md Use this snippet when you need to specify the Jira site directly within the step, without relying on environment variables. This provides explicit control over the target Jira instance. ```groovy def versions = jiraGetProjectVersions idOrKey: 'TEST', site: 'LOCAL' echo versions.data.toString() ``` -------------------------------- ### Create New Jira Version with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_new_version.md Use this snippet to create a new Jira version using the default site configured in environment variables. Ensure the 'version' object contains all necessary fields. ```groovy node { stage('JIRA') { def testVersion = [ name: 'test-version', archived: true, released: true, description: 'desc', project: 'TEST' ] jiraNewVersion version: testVersion } } ``` -------------------------------- ### Get Comments Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/comment/jira_get_comments.md This example shows how to override the default JIRA_SITE by using the `withEnv` directive. This is useful when you need to specify a different Jira site or if no global site is configured. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def comments = jiraGetComments idOrKey: 'TEST-1' echo comments.data.toString() } } } ``` -------------------------------- ### Get Issue Link Types Overriding Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_issue_link_types.md This example demonstrates how to override the default JIRA_SITE environment variable using `withEnv` or when no global site is configured. It explicitly sets the site to 'LOCAL'. ```groovy node { stage('JIRA') { withEnv(['JIRA_SITE=LOCAL']) { def issueLinkTypes = jiraGetIssueLinkTypes idOrKey: 'TEST-1', site: 'LOCAL' echo issueLinkTypes.data.toString() } } } ``` -------------------------------- ### jiraGetVersion Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_get_version.md This step queries the project version from the provided JIRA site. ```APIDOC ## jiraGetVersion ### Description This step queries the project version from the provided JIRA site. ### Method POST ### Endpoint /jiraGetVersion ### Parameters #### Input Parameters - **id** (string) - Required - version id. - **site** (string) - Optional - Default: `JIRA_SITE` environment variable. - **failOnError** (boolean) - Optional - Default: `true`. ### Request Example ```groovy jiraGetVersion id: '10000' ``` ### Response #### Success Response (200) - **data** (object) - Contains all fields returned by the JIRA API for the version. #### Response Example ```groovy { "data": { "self": "https://your-jira-instance.atlassian.net/rest/api/2/version/10000", "id": "10000", "description": "First version of the project", "name": "1.0", "project_id": "10001", "project": "PROJ", "released": true, "release_date": "2023-01-01", "archived": false, "overdue": false, "user_release_date": "01/Jan/23", "project_key": "PROJ" } } ``` ``` -------------------------------- ### Create Jira Component with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_new_component.md Use this snippet to create a Jira component using the default JIRA_SITE environment variable. Ensure the JIRA_SITE is configured globally. ```groovy node { stage('JIRA') { def testComponent = [ name: 'test-component', description: 'desc', project: 'TEST' ] jiraNewComponent component: testComponent } } ``` -------------------------------- ### Create a JIRA Issue Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/_index.md Use this step to create a new JIRA issue. Requires defining the project, summary, description, and issue type. The 'site' parameter specifies the JIRA instance. ```groovy def issue = [fields: [ project: [key: 'TESTPRO'], summary: 'New JIRA Created from Jenkins.', description: 'New JIRA Created from Jenkins.', issuetype: [name: 'Task']]] def newIssue = jiraNewIssue issue: issue, site: 'YOURJIRASITE' echo newIssue.data.key ``` -------------------------------- ### JiraGetComponent Step Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_get_component.md This step queries a particular component from the provided JIRA site. ```APIDOC ## jiraGetComponent ### Description This step queries a particular component from the provided JIRA site. ### Method POST ### Endpoint /jiraGetComponent ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **id** (string) - Required - componentId. - **site** (string) - Optional - default: `JIRA_SITE` environment variable. - **failOnError** (boolean) - Optional - default: `true`. ### Request Example ```groovy node { stage('JIRA') { def component = jiraGetComponent id: '10024' echo component.data.toString() } } ``` ### Response #### Success Response (200) - **data** (object) - Contains all the fields returned by the JIRA API for the component. #### Response Example ```json { "data": { "self": "https://your-jira-instance.atlassian.net/rest/api/2/component/10024", "id": "10024", "name": "MyComponent", "description": "This is a sample component.", "lead": { "name": "user.name", "displayName": "User Name", "active": true, "emailAddress": "user.name@example.com" }, "assigneeType": "PROJECT_LEAD", "leadUserName": "user.name", "project": "SAMPLEPROJ", "projectId": 10000 } } ``` ``` -------------------------------- ### Transition Jira Issue Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_transition_issue.md Transition a Jira issue by explicitly providing the site name. This method is suitable when environment variables are not configured or preferred. ```groovy def transitionInput = [ transition: [ id: '5' ] ] jiraTransitionIssue idOrKey: 'TEST-1', input: transitionInput, site: 'LOCAL' ``` -------------------------------- ### Get Attachment Info with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/attachment/jira_get_attachment_info.md Use this snippet to get attachment info using the default JIRA_SITE environment variable. The response data can be accessed via `response.data`. ```groovy node { stage('JIRA') { def attachment = jiraGetAttachmentInfo id: '1000' echo attachment.data.toString() } } ``` -------------------------------- ### JiraGetProject Step Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project.md Queries project info from the provided JIRA site. ```APIDOC ## jiraGetProject ### Description This queries project info from the provided JIRA site. ### Method POST ### Endpoint /jiraGetProject ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **idOrKey** (string) - Required - project id or key. - **site** (string) - Optional - default: `JIRA_SITE` environment variable. - **failOnError** (boolean) - Optional - default: `true`. ### Request Example ```json { "idOrKey": "TEST", "site": "LOCAL", "failOnError": true } ``` ### Response #### Success Response (200) - **data** (object) - Contains all fields returned by the JIRA API. #### Response Example ```json { "data": { "self": "https://your-jira-instance.atlassian.net/rest/api/2/project/10001", "id": "10001", "key": "TEST", "name": "Test Project", "projectTypeKey": "software", "simplified": false, "style": "standard" } } ``` ``` -------------------------------- ### Get Component Issue Count with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/component/jira_get_component_issue_count.md Use this snippet to get the issue count for a component using the default JIRA_SITE environment variable. Ensure the JIRA_SITE environment variable is configured globally. ```groovy node { stage('JIRA') { def count = jiraGetComponentIssueCount id: '10024' echo count.data.toString() } } ``` -------------------------------- ### Transition Jira Issue with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_transition_issue.md Use this snippet to transition a Jira issue using the default JIRA_SITE environment variable. Ensure the JIRA_SITE variable is configured globally. ```groovy node { stage('JIRA') { def transitionInput = [ transition: [ id: '5' ] ] jiraTransitionIssue idOrKey: 'TEST-1', input: transitionInput } } ``` -------------------------------- ### Get Issue Remote Link Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_get_remote_issuelink.md This step queries a particular remote link of an issue. ```APIDOC ## jiraGetIssueRemoteLink ### Description This step queries a particular remote link of an issue. ### Method POST ### Endpoint /jiraGetIssueRemoteLink ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **idOrKey** (string) - Required - issue id or key. - **linkId** (string) - Required - remote link id. - **site** (string) - Optional - default: `JIRA_SITE` environment variable. - **failOnError** (boolean) - Optional - default: `true`. ### Request Example ```json { "idOrKey": "TEST-27", "linkId": "10000", "site": "LOCAL", "failOnError": false } ``` ### Response #### Success Response (200) - **data** (object) - Contains all fields returned by JIRA API. #### Response Example ```json { "data": { "status": "success", "message": "Remote link retrieved successfully." } } ``` ``` -------------------------------- ### Get JIRA Issue Transitions Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Queries all available workflow transitions for a specific issue. Useful for determining valid transition IDs. ```groovy node { stage('Check Transitions') { def response = jiraGetIssueTransitions idOrKey: 'PROJ-123', site: 'PROD_JIRA' response.data.transitions.each { transition -> echo "Transition ID: ${transition.id}, Name: ${transition.name}, To: ${transition.to.name}" } } } ``` -------------------------------- ### jiraGetProjectComponents Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/project/jira_get_project_components.md This step queries all components of a particular project. The output can be reused in your script, and all available fields are detailed in the JIRA API documentation. ```APIDOC ## jiraGetProjectComponents ### Description This step queries all components of a particular project. ### Method POST ### Endpoint /rest/api/2/project/{projectIdOrKey}/components ### Parameters #### Path Parameters - **projectIdOrKey** (string) - Required - project id or key. #### Query Parameters - **site** (string) - Optional - default: `JIRA_SITE` environment variable. - **failOnError** (boolean) - Optional - default: `true`. ### Request Example ```json { "idOrKey": "TEST", "site": "LOCAL" } ``` ### Response #### Success Response (200) - **data** (object) - Contains all the fields returned by the JIRA API for project components. #### Response Example ```json { "data": [ { "self": "https://your-jira-instance.atlassian.net/rest/api/2/component/10000", "id": "10000", "name": "Component A", "description": "This is component A." }, { "self": "https://your-jira-instance.atlassian.net/rest/api/2/component/10001", "id": "10001", "name": "Component B", "description": "This is component B." } ] } ``` ``` -------------------------------- ### Get JIRA Issue Comments Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Retrieves all comments from a specific JIRA issue. Iterates through comments and prints author, creation date, and body. ```groovy node { stage('Get Comments') { def response = jiraGetComments idOrKey: 'PROJ-123', site: 'PROD_JIRA' response.data.comments.each { comment -> echo "Author: ${comment.author.displayName}" echo "Created: ${comment.created}" echo "Body: ${comment.body}" echo "---" } } } ``` -------------------------------- ### Create New JIRA Version Source: https://context7.com/jenkinsci/jira-steps-plugin/llms.txt Creates a new version (fix version) in a JIRA project. Sets release and archive status, start and release dates. ```groovy node { stage('Create Version') { def version = [ name: "v${env.RELEASE_VERSION}", description: "Release version ${env.RELEASE_VERSION}", project: 'PROJ', released: false, archived: false, startDate: '2024-01-15', releaseDate: '2024-02-01' ] def response = jiraNewVersion version: version, site: 'PROD_JIRA' if (response.successful) { echo "Created version: ${response.data.name} (ID: ${response.data.id})" env.VERSION_ID = response.data.id } } } ``` -------------------------------- ### Get Issue Watches with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/watcher/jira_get_issue_watches.md Use this snippet to retrieve issue watchers when a default JIRA_SITE is configured globally. The response data can be accessed via `response.data`. ```groovy node { stage('JIRA') { def watches = jiraGetIssueWatches idOrKey: 'TEST-1' echo watches.data.toString() } } ``` -------------------------------- ### Create New Jira Version Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/version/jira_new_version.md Use this snippet when no environment variables for the Jira site are available or desired. The 'site' parameter must be explicitly provided. ```groovy def testVersion = [ name: 'test-version', archived: true, released: true, description: 'desc', project: 'TEST' ] jiraNewVersion version: testVersion, site: 'LOCAL' ``` -------------------------------- ### Get JIRA Fields Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_fields.md Use this snippet when you need to specify the JIRA site directly within the script, bypassing any environment variable configurations. ```groovy def fields = jiraGetFields idOrKey: 'TEST-1', site: 'LOCAL' echo fields.data.toString() ``` -------------------------------- ### Configure Jira Sites with Configuration as Code Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/getting-started/config/casc.md Use this YAML snippet to define multiple Jira sites in the global configuration. It supports both BASIC and OAuth authentication methods, along with specific timeouts and search API versions. ```yaml unclassified: jiraStepsConfig: sites: - name: 'another' url: 'http://example.com' timeout: 10000 readTimeout: 10000 loginType: 'BASIC' userName: 'foo' password: 'some pass' useV3Search: true - name: 'moar jira' url: 'http://example.com' timeout: 10000 readTimeout: 10000 loginType: 'OAUTH' consumerKey: 'my consumer key' privateKey: 'my private key' secret: 'super secret' token: 'my token' useV3Search: false ``` -------------------------------- ### Get JIRA Fields with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_fields.md Use this snippet to fetch JIRA fields when the JIRA_SITE environment variable is configured globally. The response data can be accessed and processed. ```groovy node { stage('JIRA') { def fields = jiraGetFields idOrKey: 'TEST-1' echo fields.data.toString() } } ``` -------------------------------- ### Configure Jira Sites via Jenkins Script Console Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/getting-started/config/script.md Use this script in the Jenkins Script Console to add and configure Jira sites. It supports both BASIC and OAuth authentication. Ensure the necessary JSON libraries are available. ```groovy import net.sf.json.JSONArray import net.sf.json.JSONObject import org.thoughtslive.jenkins.plugins.jira.JiraStepsConfig import org.thoughtslive.jenkins.plugins.jira.Site //global user-defined configuration JSONArray sitesConf = [ [ name: 'another', url: 'http://example.com', timeout: 10000, readTimeout: 10000, loginType: 'BASIC', userName: 'foo', password: 'some pass' ], [ name: 'moar jira', url: 'http://example.com', timeout: 10000, readTimeout: 10000, loginType: 'OAUTH', consumerKey: 'my consumer key', privateKey: 'my private key', secret: 'super secret', token: 'my token' ] ] as JSONArray //get global Jenkins configuration JiraStepsConfig.ConfigDescriptorImpl config = Jenkins.instance.getExtensionList(JiraStepsConfig.ConfigDescriptorImpl.class)[0] ArrayList sites = new ArrayList() //configure new sites from the above JSONArray sitesConf.each { s -> String loginType = s.optString('loginType', '').toUpperCase() if(loginType in ['BASIC', 'OAUTH']) { Site site = new Site(s.optString('name',''), new URL(s.optString('url', '')), s.optString('loginType', ''), s.optInt('timeout', 10000)) if(loginType == 'BASIC') { site.setUserName(s.optString('userName', '')) site.setPassword(s.optString('password', '')) site.setReadTimeout(s.optInt('readTimeout', 10000)) } else { //loginType is OAUTH site.setConsumerKey(s.optString('consumerKey', '')) site.setPrivateKey(s.optString('privateKey', '')) site.setSecret(s.optString('secret', '')) site.setToken(s.optString('token', '')) site.setReadTimeout(s.optInt('readTimeout', 10000)) } sites.add(site) } } //set our defined sites config.setSites(sites.toArray(new Site[0])) //persist configuration to disk as XML config.save() ``` -------------------------------- ### Create New Jira Issues with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_new_issues.md Use this snippet to create new Jira issues in bulk using the default JIRA_SITE environment variable. Ensure the IssueInput class is understood for field definitions. ```groovy node { stage('JIRA') { # Look at IssueInput class for more information. def testIssue1 = [fields: [ project: [id: '10000'], summary: 'New JIRA Created from Jenkins.', description: 'New JIRA Created from Jenkins.', issuetype: [id: '3']]] def testIssue2 = [fields: [ project: [id: '10000'], summary: 'New JIRA Created from Jenkins.', description: 'New JIRA Created from Jenkins.', issuetype: [id: '3']]] def testIssues = [issueUpdates: [testIssue1, testIssue2]] response = jiraNewIssues issues: testIssues echo response.successful.toString() echo response.data.toString() } } ``` -------------------------------- ### Link Jira Issues with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issuelink/jira_link_issues.md Links two JIRA issues using the default JIRA_SITE environment variable. Ensure the JIRA_SITE environment variable is configured globally. ```groovy node { stage('JIRA') { jiraLinkIssues type: 'Relates', inwardKey: 'TEST-1', outwardKey: 'TEST-2' } } ``` -------------------------------- ### Get Jira Issue Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/issue/jira_get_issue.md Retrieve a JIRA issue by explicitly providing the site name as a parameter, suitable for environments without pre-configured JIRA_SITE variables. ```groovy def issue = jiraGetIssue idOrKey: 'TEST-1', site: 'LOCAL' echo issue.data.toString() ``` -------------------------------- ### Search Users Without Environment Variables Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/user/jira_assignable_user_search.md Searches for users by query string, project, and site, explicitly setting failOnError to true. The response data is printed. ```groovy def users = jiraAssignableUserSearch queryStr: 'jenkin', project: 'TEST', site: 'LOCAL', failOnError: true echo users.data.toString() ``` -------------------------------- ### Download Attachment with Default Site Source: https://github.com/jenkinsci/jira-steps-plugin/blob/master/hugo/content/steps/attachment/jira_download_attachment.md Use this snippet to download an attachment using the default JIRA_SITE environment variable. Ensure the JIRA_SITE is configured globally. ```groovy node { stage('JIRA') { def attachment = jiraDownloadAttachment id: '1000', file: 'test.txt', override: false echo attachment.data.toString() } } ```