Jira Software Cloud を Jenkins と連携する

OAuth を使用した自己ホスト型ツールとの連携

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

This integration is currently in an Early Access Program. If you'd like to use this integration, please sign up through this form.


This integration exists to provide a free, easy, secure, and reliable way to connect your Jenkins server, running behind the firewall, and Jira Software Cloud. Simply add a few extra lines in the Jenkinsfile that defines your pipeline steps and the integration will start sending build and deployment data to Jira and associate that information with the relevant Jira issues.

This gives your entire team additional visibility and context on every issue detail view in Jira, showing the latest build status or if that work has been successfully deployed to an environment.

You can also use this information to search across issues using the Jira Query Language (JQL), easily answering questions like “which issues in the current sprint have been deployed to production”. You can even add these as quick filters on your boards!

はじめる前に


Time: 15-30 mins

前提条件

  • You're a site administrator of your Jira Software Cloud site.

  • You're an admin in Jenkins and you can install, update, and delete plugins.

  • You're using a ‘Multibranch Pipeline’ in Jenkins (this is the only item supported in Jenkins today).

  • You can edit the Jenkinsfile in your source code/repo for the pipeline(s) you want to use this integration with.

  • Your team should be adding issue keys (e.g. FUSE-123) as part of their commit messages (for deployment information) and branch names (for build information). If your team isn't already following this pattern, you can read more here.


Jira Software Cloud と Jenkins のリンク方法

Jenkins 用の OAuth 認証情報を Jira で作成

  1. Jira ホーム > [Jira 設定] > [アプリ] に移動します。

  2. [OAuth 認証情報] を選択します。

  3. [認証情報の作成] を選択します。

  4. 以下の詳細を入力してください。

    • アプリ名 - Jenkins

    • App logo - A URL to the Jenkins logo, which will be used as an icon in the list of credentials. Eg: https://jenkins.yourcompany.com/logo.png

    • Server base URL - The URL to your Jenkins server. Eg: https://jenkins.yourcompany.com/


Jenkins プラグインのインストール

  1. Login to your Jenkins server and navigate to the Plugin Manager.

  2. Click on the ‘Advanced’ tab at the top

  3. Change the URL under ‘Update Site’ to include the list of experimental plugins by updating the URL to include /experimental/ in it. It should look like https://updates.jenkins.io/experimental/update-center.json

  4. Click submit and refresh the list of plugins via the ‘check now’ button in the bottom right.

  5. Select the “Available” tab and search for the ‘Atlassian Jira Software Cloud’ plugin. Install it.

  6. (Optional) You can change your Update Site URL back to https://updates.jenkins.io/update-center.json if you would like. It will not affect any already installed experimental plugins.

追加情報:


Jenkins 認証情報のセットアップ

  1. In Jenkins, go to Manage Jenkins > Configure System screen and scroll to the Jira Software Cloud integration section.

  2. [Add Jira Cloud Site] > [Jira Cloud Site] を選択します。[Site name]、[ClientID]、[Secret] フィールドが表示されます

  3. 以下の詳細を入力してください。

    • Site name: Jira Cloud サイトの URL。例: yourcompany.atlassian.net

    • Client ID: [OAuth 認証情報] 画面 ([クライアント ID] 列) からコピーします。

    • Secret: [Add] > [Jenkins] を選択します。

      • [Kind] では、[Secret text] を選択します。

      • [Secret] は、[OAuth 認証情報] 画面 ([シークレット] 列) からコピーします。

      • [Description] には説明を指定します。

  4. [Test connection] を選択して、Jira サイトで認証情報が有効であることを確認します。

How to use the integration

To start using the integration:

  1. Go into a specific pipeline in Jenkins.

  2. From the left-hand menu, select Pipeline Syntax.

  3. In the Snippet Generator, select jiraSendDeploymentInfo or jiraSendBuildInfo from the dropdown list of Sample Steps and fill in the relevant details.

  4. Select Generate Pipeline Script and copy/paste the output into your Jenkinsfile, wherever you want to notify Jira.


For sending build information

This is an example snippet of a very simple ‘build’ stage set up in a Jenkinsfile. After the pipeline is run, it will post the build information to your Jira Cloud site by looking at the branch name. If there is a Jira issue key (e.g. “TEST-123”) in the branch name, it will send the data over to Jira.

stage('Build') {
   steps {
       echo 'Building...'
   }
   post {
       always {
           jiraSendBuildInfo site: '<sitename>.atlassian.net'
       }
   }
}


For sending deployment information

This is an example snippet of a stage that runs on any change to the master branch. Again, we use a post step to send deployment data to Jira and the relevant issues. Here, the environmentId, environmentName, and environmentType need to be set to whatever you want to appear in Jira.

stage('Deploy - Production') {
   when {
       branch 'master'
   }
   steps {
       echo 'Deploying to Production from master...'
   }
   post {
       always {
           jiraSendDeploymentInfo site: '<sitename>.atlassian.net', environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production'
       }
   }
}


If set up properly, whenever you make a commit or merge a PR in your SCM tool, like Bitbucket or GitHub, it should run the Jenkins pipeline you have specified for that repo. The build and deployment information will be visible on the issue detail view along the right-hand side.



最終更新日 2019 年 8 月 22 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.