{"componentChunkName":"component---src-templates-post-js","path":"/blog/projects/jira-ci-cd-integration-for-builds-deploys/","result":{"data":{"header":{"childImageSharp":{"fluid":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAMCBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAHjiagKm0wchP/EABwQAAMAAQUAAAAAAAAAAAAAAAECAwAQEhMxQf/aAAgBAQABBQKKclKrtbJsFNCug68z/8QAFREBAQAAAAAAAAAAAAAAAAAAIEH/2gAIAQMBAT8Bg//EABURAQEAAAAAAAAAAAAAAAAAACBB/9oACAECAQE/AaP/xAAcEAACAgIDAAAAAAAAAAAAAAABEQACECEgMWH/2gAIAQEABj8CFeomCPMbq5qq4//EABsQAQABBQEAAAAAAAAAAAAAAAEAEBEhMUFR/9oACAEBAAE/IcuA6sv44DQgdOMbXvc0Gk9U/9oADAMBAAIAAwAAABDb537/xAAVEQEBAAAAAAAAAAAAAAAAAAABEP/aAAgBAwEBPxACCf/EABYRAAMAAAAAAAAAAAAAAAAAAAERIP/aAAgBAgEBPxBmH//EAB0QAQABBAMBAAAAAAAAAAAAAAERABAxQSFRYaH/2gAIAQEAAT8QndiXQAmg3lAIlj6FYCpD3QEJaJ+OLB4RUEYcpm3/2Q==","aspectRatio":1,"src":"/static/5a125f11859148d0d0aadc1049ac37f7/82bc5/photo_2020-01-05_20-24-37.jpg","srcSet":"/static/5a125f11859148d0d0aadc1049ac37f7/b736e/photo_2020-01-05_20-24-37.jpg 25w,\n/static/5a125f11859148d0d0aadc1049ac37f7/b2767/photo_2020-01-05_20-24-37.jpg 50w,\n/static/5a125f11859148d0d0aadc1049ac37f7/82bc5/photo_2020-01-05_20-24-37.jpg 100w,\n/static/5a125f11859148d0d0aadc1049ac37f7/decd9/photo_2020-01-05_20-24-37.jpg 150w,\n/static/5a125f11859148d0d0aadc1049ac37f7/3dcee/photo_2020-01-05_20-24-37.jpg 200w,\n/static/5a125f11859148d0d0aadc1049ac37f7/883ec/photo_2020-01-05_20-24-37.jpg 640w","srcWebp":"/static/5a125f11859148d0d0aadc1049ac37f7/4226e/photo_2020-01-05_20-24-37.webp","srcSetWebp":"/static/5a125f11859148d0d0aadc1049ac37f7/12e7b/photo_2020-01-05_20-24-37.webp 25w,\n/static/5a125f11859148d0d0aadc1049ac37f7/ecb58/photo_2020-01-05_20-24-37.webp 50w,\n/static/5a125f11859148d0d0aadc1049ac37f7/4226e/photo_2020-01-05_20-24-37.webp 100w,\n/static/5a125f11859148d0d0aadc1049ac37f7/e8bcc/photo_2020-01-05_20-24-37.webp 150w,\n/static/5a125f11859148d0d0aadc1049ac37f7/1c9b5/photo_2020-01-05_20-24-37.webp 200w,\n/static/5a125f11859148d0d0aadc1049ac37f7/2420f/photo_2020-01-05_20-24-37.webp 640w","sizes":"(max-width: 100px) 100vw, 100px","presentationWidth":100}}},"page":{"fields":{"url":"/blog/projects/jira-ci-cd-integration-for-builds-deploys/"},"frontmatter":{"title":"Jira CI/CD Integration","subtitle":"Have your builds and deployments show up in Jira","keywords":["developer","integration","software","jira","gitlab","drone","actions","cloud-build","continuous","deployments","builds","ci-cd"],"template":"post","canonical_url":"","noindex":null,"date":"2021-08-08T05:00:00.000Z","tweet":"https://twitter.com/rohit_gohri/status/1424251512809693190","github":"rohit-gohri/jira-ci-cd-integration","content_img_path":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='450'%20height='300'%20viewBox='0%200%20450%20300'%20preserveAspectRatio='none'%3e%3cpath%20d='M195%202a150%20150%200%2010171%20195c9-22%2011-53%207-74A152%20152%200%2000195%202m-7%2029v28l1%2026h34l36-1%201-27V31l-36-1-36%201m33%2024c-5%2014-5%2015-2%2015s3-1%207-12l5-13c0-2%200-2-3-2-2%200-3%200-7%2012m-14-6c-8%207-8%208%200%2014%206%205%206%205%207%203s1-3-3-6l-4-4%204-3c4-3%204-4%203-6v-3l-7%205m26-3c-1%202%200%203%203%206l4%204-4%204c-3%203-4%204-3%206l1%202c1%200%2013-10%2013-12l-7-7c-6-5-6-5-7-3M132%20168l-32%2013c-1%202%2015%2048%2017%2051%202%201%2065-22%2066-24v-5l-9-23c-8-24-8-23-9-23-1-1-16%205-33%2011m151-8a7414%207414%200%2001-17%2046c0%202%206%204%2032%2014l32%2012c2%200%203-2%2013-27%207-19%208-22%207-23-2-2-61-25-64-25l-3%203m-135%2017c-2%200-1%204%201%205%202%200%206%207%206%2011l1%204c1%202-1%202-3%200-1-3-4-3-5%200l-3%201c-2-2-5%200-5%202s0%202-1%201l-3-1c-2%200-2%201-2%204%200%204-2%204-4-1-3-9-4-12-3-13s0-5-1-5c-5%200-7%205-5%2011v3c-1%201%200%205%201%205l4%204c1%204%204%206%208%205%202-1%202-2%201-4l1-2%203-2%204-1%203-2c2-2%209-2%2010%200%201%205%208%200%206-5v-7c0-3%200-4-2-5l-4-4c-1-4-4-6-8-4m157%2018c-3%207-3%208-1%209%203%202%203%201%206-7%204-8%204-8%200-8-2-1-3-1-5%206m16%203c-4%2011-4%2011%200%2012%203%201%2011-19%208-21s-4-1-8%209'%20fill='%23d3d3d3'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.4513274336283186,"src":"/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/69339/cd_icon.jpg","srcSet":"/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/4aede/cd_icon.jpg 164w,\n/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/7ae0f/cd_icon.jpg 326w,\n/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/69339/cd_icon.jpg 652w,\n/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/cd8c8/cd_icon.jpg 872w","srcWebp":"/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/4fe5d/cd_icon.webp","srcSetWebp":"/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/74efb/cd_icon.webp 164w,\n/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/5da3e/cd_icon.webp 326w,\n/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/4fe5d/cd_icon.webp 652w,\n/static/cd7cbc68f1e5a2aaec99b4fc6ab70d7e/1152e/cd_icon.webp 872w","sizes":"(max-width: 652px) 100vw, 652px","presentationWidth":652}}}}}},"pageContext":{"url":"/blog/projects/jira-ci-cd-integration-for-builds-deploys/","relativePath":"blog/projects/jira-ci-cd-integration-for-builds-deploys.md","relativeDir":"blog/projects","base":"jira-ci-cd-integration-for-builds-deploys.md","name":"jira-ci-cd-integration-for-builds-deploys","html":"<p>Ever wanted to get build and deployment links directly in Jira? Now you can, just add this small step to the last stage of your pipeline and get all the relevant information right in the ticket details page.</p>\n<p><img src=\"https://raw.githubusercontent.com/rohit-gohri/jira-ci-cd-integration/main/docs/builds-panel.png\" alt=\"Builds Panel Preview\"></p>\n<h2>Generate Credentials for OAuth App</h2>\n<p>Generate new OAuth Credentials and copy</p>\n<p><strong>See:</strong> <a href=\"https://support.atlassian.com/jira-cloud-administration/docs/integrate-with-self-hosted-tools-using-oauth/\" target=\"_blank\" rel=\"noopener noreferrer\">https://support.atlassian.com/jira-cloud-administration/docs/integrate-with-self-hosted-tools-using-oauth/</a></p>\n<p><img src=\"https://raw.githubusercontent.com/rohit-gohri/jira-ci-cd-integration/main/docs/oauth-creds.png\" alt=\"OAuth Creds Screen\"></p>\n<h2>Use with Any CI/CD Provider</h2>\n<p>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 Build.</p>\n<p>Docker Images are available from:</p>\n<div class=\"no-border\">\n<ul>\n<li>Github Container Registry: <a href=\"https://github.com/-/rohit-gohri/packages/container/package/jira-ci-cd-integration\" target=\"_blank\" rel=\"noopener noreferrer\"><code>ghcr.io/rohit-gohri/jira-ci-cd-integration</code></a></li>\n<li>Gitlab Container Registry: <a href=\"https://gitlab.com/rohit-gohri/jira-ci-cd-integration/container_registry/2072732\" target=\"_blank\" rel=\"noopener noreferrer\"><code>registry.gitlab.com/rohit-gohri/jira-ci-cd-integration</code></a></li>\n<li>Docker Hub: <a href=\"https://hub.docker.com/r/boringdownload/jira-integration\" target=\"_blank\" rel=\"noopener noreferrer\"><code>boringdownload/jira-integration</code></a></li>\n</ul>\n</div>\n<p>Pick whatever you want and is convenient for you.</p>\n<p>Configuration is through Environment Variables. Read more in the <a href=\"https://github.com/rohit-gohri/jira-ci-cd-integration#options\" target=\"_blank\" rel=\"noopener noreferrer\">repository Readme</a>.</p>\n<h3>Jira Drone.io Example</h3>\n<span class=\"no-border\">\n<p><a href=\"https://cloud.drone.io/rohit-gohri/jira-ci-cd-integration\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https://cloud.drone.io/api/badges/rohit-gohri/jira-ci-cd-integration/status.svg?ref=refs/tags/v0\" alt=\"Build Status\"></a></p>\n</span>\n<p><a href=\"https://docs.drone.io/pipeline/environment/syntax/#from-secrets\" target=\"_blank\" rel=\"noopener noreferrer\">Add secrets</a> for <code>JIRA_CLIENT_ID</code> and <code>JIRA_CLIENT_SECRET</code> and then add this to your pipeline:</p>\n<pre><code class=\"language-yaml\">steps:\n  - name: jira-integration\n    image: boringdownload/jira-integration:v0\n    environment:\n      BUILD_NAME: drone-pipeline\n      JIRA_INSTANCE: companyname\n      JIRA_CLIENT_ID:\n        from_secret: jira_client_id\n      JIRA_CLIENT_SECRET:\n        from_secret: jira_client_secret\n</code></pre>\n<h4>Jira Gitlab CI/CD</h4>\n<span class=\"no-border\">\n<p><a href=\"https://gitlab.com/rohit-gohri/jira-ci-cd-integration/-/commits/v0\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https://gitlab.com/rohit-gohri/jira-ci-cd-integration/badges/v0/pipeline.svg\" alt=\"pipeline status\"></a></p>\n</span>\n<p><a href=\"https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project\" target=\"_blank\" rel=\"noopener noreferrer\">Add a CI/CD Variable to your project</a> for <code>JIRA_CLIENT_ID</code> and <code>JIRA_CLIENT_SECRET</code> (remember to mask them) and then add these steps to your pipeline (we use <code>.post</code> stage so it runs last)</p>\n<pre><code class=\"language-yaml\">jira-integration-on-success:\n  stage: .post\n  when: on_success\n  image: registry.gitlab.com/rohit-gohri/jira-ci-cd-integration:v0\n  script: jira-integration\n  variables:\n    BUILD_STATE: successful\n    BUILD_NAME: gitlab-pipeline\n    JIRA_INSTANCE: companyname\n\njira-integration-on-failure:\n  extends: jira-integration-on-success\n  when: on_failure\n  variables:\n    BUILD_STATE: failure\n</code></pre>\n<h3>Usage With Github Actions</h3>\n<p>You can also use this as a Github Action if you want to send release information to Jira.</p>\n<span class=\"no-border\">\n<p><a href=\"https://github.com/rohit-gohri/jira-ci-cd-integration/actions/workflows/test-release.yml\" target=\"_blank\" rel=\"noopener noreferrer\"><img src=\"https://github.com/rohit-gohri/jira-ci-cd-integration/actions/workflows/test-release.yml/badge.svg\" alt=\"test-release workflow\"></a></p>\n</span>\n<p>First add OAuth Creds as secrets to Github (<strong>See:</strong> <a href=\"https://docs.github.com/en/actions/reference/encrypted-secrets\" target=\"_blank\" rel=\"noopener noreferrer\">https://docs.github.com/en/actions/reference/encrypted-secrets</a>)</p>\n<ul>\n<li>Add Client ID as <code>JIRA_CLIENT_ID</code></li>\n<li>Add Client Secret as <code>JIRA_CLIENT_SECRET</code></li>\n</ul>\n<p><img src=\"https://raw.githubusercontent.com/rohit-gohri/jira-ci-cd-integration/main/docs/github-secrets.png\" alt=\"Github Secrets\"></p>\n<h4>Use in Builds Pipeline</h4>\n<pre><code class=\"language-yaml\">- name: Jira Integration\n  if: ${{ always() }}\n  uses: rohit-gohri/jira-ci-cd-integration@v0\n  with:\n    event_type: build\n    state: ${{ job.status }}\n    jira_instance: companyname # Subdomain for Jira Cloud\n    client_id: ${{ secrets.JIRA_CLIENT_ID }}\n    client_secret: ${{ secrets.JIRA_CLIENT_SECRET }}\n</code></pre>\n<h4>Use in Deployment Pipeline</h4>\n<pre><code class=\"language-yaml\">- name: Jira Integration\n  if: ${{ always() }}\n  uses: rohit-gohri/jira-ci-cd-integration@v0\n  with:\n    event_type: deployment\n    state: ${{ job.status }}\n    issue: JCI-3, JCI-6 # Comma separated list of issues being deployed/released. You are expected to generate this yourself in a previous step\n    jira_instance: companyname # Subdomain for Jira Cloud\n    client_id: ${{ secrets.JIRA_CLIENT_ID }}\n    client_secret: ${{ secrets.JIRA_CLIENT_SECRET }}\n</code></pre>\n<h2>Result</h2>\n<p>That's all it takes. You'll get Builds information like you do for Branches and Pull Requests:</p>\n<p><img src=\"/images/projects/jira-ci-cd/result.png\" alt=\"result\"></p>\n<div class=\"no-border\">\n<blockquote>\n<p>Image: <a href=\"https://thenounproject.com/term/continuous-deployment/2661846/\" target=\"_blank\" rel=\"noopener noreferrer\">continuous deployment by Shocho from the Noun Project</a></p>\n</blockquote>\n</div>","headerImg":"photo_2020-01-05_20-24-37.jpg"}},"staticQueryHashes":["1161966454","1673585186","1866307108","219491723","2948329147","3269044456","629512913"]}