DEV Community

Rohit Gohri
Rohit Gohri

Posted on • Originally published at rohit.page on

Jira CI/CD Integration

Integrate your CI/CD pipeline's Build and Deployment information into the Jira Development Panel. Enable better

Builds Panel Preview

Only supports Jira Cloud. Does not support Jira Server (hosted)

Prerequisites

Generate Credentials

Generate new OAuth Credentials and copy

See: https://support.atlassian.com/jira-cloud-administration/docs/integrate-with-self-hosted-tools-using-oauth/

OAuth Creds Screen

Use with Any CI/CD Provider

As long as your CI/CD provider supports running Docker images you may use this integration. Tested in Drone.io, Gitlab CI, and Google Cloud Run.

Docker Images are available from:

  • Gitlab Container Registry: registry.gitlab.com/rohit-gohri/jira-ci-cd-integration
  • Github Container Registry: ghcr.io/rohit-gohri/jira-ci-cd-integration
  • Docker Hub: boringdownload/jira-integration

Pick whatever you want and is convenient for you.

Set Env Vars

Configuration for the Docker image is through env vars. Read more in options.

Jira-Gitlab CI/CD

pipeline status

Add a CI/CD Variable to your project for JIRA_CLIENT_ID and JIRA_CLIENT_SECRET (remember to mask them) and then add these steps to your pipeline (we use .post stage so it runs last)

jira-integration-on-success:
  stage: .post
  when: on_success
  image: registry.gitlab.com/rohit-gohri/jira-ci-cd-integration:v0
  script: jira-integration
  variables:
    BUILD_STATE: successful
    BUILD_NAME: gitlab-pipeline
    JIRA_INSTANCE: companyname

jira-integration-on-failure:
  extends: jira-integration-on-success
  when: on_failure
  variables:
    BUILD_STATE: failure

Enter fullscreen mode Exit fullscreen mode

Jira-Drone.io Example

Build Status

Add secrets for JIRA_CLIENT_ID and JIRA_CLIENT_SECRET and then add this to your pipeline:

steps:
  - name: jira-integration
    image: boringdownload/jira-integration:v0
    environment:
      BUILD_NAME: drone-pipeline
      JIRA_INSTANCE: companyname
      JIRA_CLIENT_ID:
        from_secret: jira_client_id
      JIRA_CLIENT_SECRET:
        from_secret: jira_client_secret

Enter fullscreen mode Exit fullscreen mode

Usage With Github Actions

You can also use this as a Github Action if you want to send release information to Jira.

test-release workflow

Add OAuth Creds as secrets to Github

See: https://docs.github.com/en/actions/reference/encrypted-secrets

  • Add Client ID as JIRA_CLIENT_ID
  • Add Client Secret as JIRA_CLIENT_SECRET

Github Secrets

Update Github Workflow

Use in Builds Pipeline

- name: Jira Integration
  if: ${{ always() }}
  uses: rohit-gohri/jira-ci-cd-integration@v0
  with:
    event_type: build
    state: ${{ job.status }}
    jira_instance: companyname # Subdomain for Jira Cloud
    client_id: ${{ secrets.JIRA_CLIENT_ID }}
    client_secret: ${{ secrets.JIRA_CLIENT_SECRET }}

Enter fullscreen mode Exit fullscreen mode

Use in Deployment Pipeline

- name: Jira Integration
  if: ${{ always() }}
  uses: rohit-gohri/jira-ci-cd-integration@v0
  with:
    event_type: deployment
    state: ${{ job.status }}
    issue: JCI-3, JCI-6 # Comma separated list of issues being deployed/released. You are expected to generate this yourself in a previous step
    jira_instance: companyname # Subdomain for Jira Cloud
    client_id: ${{ secrets.JIRA_CLIENT_ID }}
    client_secret: ${{ secrets.JIRA_CLIENT_SECRET }}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)