此内容没有您所选择的语言版本。
Chapter 11. Connecting to Jira
In an integration, you can connect to a Jira server to obtain, create, or update issues. Jira is a tool for planning, tracking, and managing software development projects. Each Jira environment allows customization of the workflow, which has an effect on the details for connecting to Jira in an integration. Consulting with your Jira administrator should clarify the details.
Connecting to Jira is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. For more information about the support scope of Red Hat Technology Preview features, see https://access.redhat.com/support/offerings/techpreview/.
The following topics provide information and procedures for creating integrations that connect to a Jira server:
- Section 11.1, “Registering Fuse Online with a Jira server that uses OAuth”
- Section 11.2, “Creating a Jira connection”
- Section 11.3, “Obtaining Jira issues or comments to trigger integration execution”
- Section 11.4, “Adding an issue to a Jira server”
- Section 11.5, “Adding a comment to a Jira issue”
- Section 11.6, “Attaching a file to a Jira issue”
- Section 11.7, “Adding and removing Jira issue watchers”
- Section 11.8, “Updating an issue on a Jira server”
- Section 11.9, “Transitioning a Jira issue to a new status”
11.1. Registering Fuse Online with a Jira server that uses OAuth
An integration can connect to a Jira server that uses the OAuth protocol to authenticate access. To enable this, register your Fuse Online environment as a Jira client application. Jira client applications are also referred to as Jira consumers. In other words, your Fuse Online environment is a Jira consumer.
Registration is not required when a Jira server uses only basic authentication.
Follow the procedure here to obtain the Jira OAuth credentials that you need to create a Fuse Online connection to Jira. For more details about registering Jira consumers, including a tutorial that takes you through the steps with a sample server, see the Jira documentation about OAuth for REST APIs
After you register Fuse Online with a Jira server, you use Fuse Online to create a connection to that Jira server. Any number of integrations can use the same Jira connection. However, if you want to create another Jira connection, you must obtain another set of OAuth credentials by repeating the registration procedure provided here.
Overview of the main steps
The main steps in the registration procedure are:
- Obtain the Atlassian command line application that enables you to obtain OAuth credentials.
-
Run the downloaded application to create a
config.properties
file. - Create a public/private key pair, which Fuse Online uses to access a Jira server.
-
Edit the
config.properties
file to update some of its values. - Configure your Jira server to recognize your Fuse Online environment as a consumer application.
- Obtain a Jira access token that Fuse Online needs to access data on your Jira server.
Each of these steps has several substeps and the procedure below provides the details.
Prerequisites
- Jira server administration permissions.
- Familiarity with command line interfaces.
Procedure
Obtain the Atlassian command line application that enables you to obtain OAuth credentials:
-
Go to the
atlassian-oauth-examples
page. - In the left panel, at the bottom, click Downloads.
- On the Downloads page, click Download repository.
- Extract the file into a directory that you choose.
-
Go to the
Run the downloaded application to create a
config.properties
file for OAuth credentials:- In a terminal, navigate to the directory that contains the extracted content.
Change to the
java
directory and build the client:cd atlassianlabs-atlassian-oauth-examples-dd0264cad043/java mvn clean compile assembly:single
Change to the
target
directory and generate theconfig.properties
file:cd target java -jar OAuthTutorialClient-1.0.jar requestToken
You can ignore the connection exception. In the
target
directory, there is now aconfig.properties
file that contains some temporary keys.Generate a public/private key pair that Fuse Online needs for access to a Jira server. While you can run these commands anywhere, the first instruction directs you to a particular directory for convenience:
- Navigate to the directory that contains the downloaded application.
Generate a private key:
openssl genrsa -out jira_privatekey.pem 1024
Obtain a public key:
openssl req -newkey rsa:1024 -x509 -key jira_privatekey.pem -out jira_publickey.cer -days 365
This command prompts you to enter information about your Fuse Online environment. Alternatively, to avoid responding to prompts, add the
-subj
option to the command. For example, at the end of the command line above, add something like this:-subj "/C=US/ST=New York/L=New York/O=MyCompany Ltd./OU=IT/CN=mysubdomain.mydomain.com"
Export the keys:
openssl pkcs8 -topk8 -nocrypt -in jira_privatekey.pem -out jira_privatekey.pcks8 openssl x509 -pubkey -noout -in jira_publickey.cer > jira_publickey.pem
You now have four files:
jira_privatekey.pcks8
jira_privatekey.pem
jira_publickey.cer
jira_publickey.pem
Obtain the private key, without the header, line breaks, and footer:
cat jira_privatekey.pcks8 | grep -v 'PRIVATE'|awk '{print}' ORS=''
- Copy the private key to the clipboard.
Edit the
config.properties
file:-
Navigate to the
java/target
directory that contains theconfig.properties
file and open the file for editing. -
In the
config.properties
file, replace the private key with the private key that you copied to the clipboard. Change the
jira_home
setting to the URL for your Jira server. Be sure to specifyhttps
if your Jira server useshttps
. Also, you need to escape the colon. For example:jira_home=https\://issues.mycompany.org
Change the
consumer_key
setting toFuse Online App
. For example:consumer_key=Fuse Online App
-
Save and close the
config.properties
file.
-
Navigate to the
Configure your Jira server to recognize your Fuse Online environment as a consumer application. You must be logged in to the Jira server as an administrative user.
- Select Settings ( ) > Products > Application links.
In the Create new link input field, enter any URL, for example, enter:
https://example.com
.This displays a dialog that indicates that no response was received, which is okay because only one-way communication is required.
Click Continue to display the Link applications dialog. In this dialog:
-
In the Consumer Key field, enter
Fuse Online App
. - At the bottom, select Create incoming link.
- In each of the other fields, enter any value. Each field requires a value. The value that you enter does not matter because no response is needed.
- Click Continue to display another dialog.
-
In the Consumer Key field, enter
Fuse Online App
. -
In the Consumer Name field, enter
Fuse Online App
. -
In the Public Key field, paste the public key that is in the
jira_publickey.pem
file. Be sure to paste only the key without the header and footer. To display the key so that you can copy it, in the directory that contains thejira_publickey.pem
file, entercat jira_publickey.pem
. - Click Continue.
-
In the Consumer Key field, enter
Obtain a Jira access token that Fuse Online needs to access data on your Jira server. In the Jira OAuth documentation that is linked to at the beginning of this procedure, this step is referred to as "The Oauth dance" because there are exchanges among Fuse Online, the Jira server, and the Jira administrator.
-
Navigate to the
java/target
directory in the directory that contains the command line application that you downloaded in the first step of this whole procedure. Obtain a request token from your Jira server:
java -jar OAuthTutorialClient-1.0.jar requestToken
This displays something like:
Token: ec3dj4byySM5ek3XW7gl7f4oc99obAlo Token Secret: OhONj0eF7zhXAMKZLbD2Rd3x7Dmxjy0d Retrieved request token. go to https://jira101.atlassian.net/plugins/servlet/oauth/authorize?oauth_token=ec3dj4byySM5ek3XW7gl7f4oc99obAlo to authorize it
- In another browser tab, go to the URL provided in that output. That page welcomes you to Jira and prompts you to allow access to the Fuse Online App.
- Click Allow, which displays an Access Approved page with a verification code.
- Copy the verification code to the clipboard and paste it somewhere so that you can easily retrieve it.
Obtain an access token by invoking a command such as the following. In the following command line example, the last value is a verification code. In the command that you run, replace the example verification code with the verification code that you copied in the previous step. For example:
java -jar OAuthTutorialClient-1.0.jar accessToken qTJkPi
The output from this command is the access token that Fuse Online needs to access your Jira server.
-
Navigate to the
Result
The Jira command line application updates the config.properties
file so that it contains all values that you need to configure a Jira connection for Fuse Online.
Next step
Create a Jira connection.
11.2. Creating a Jira connection
In an integration, to obtain, create, or update a Jira issue, create a Jira connection, which you then add to an integration. You can add the same connection to any number of integrations.
If the Jira server that you want to connect to uses the OAuth protocol for authenticating access, you must have registered your Fuse Online environment as a client of the Jira server that you want to connect to. See Registering Fuse Online with a Jira server that uses OAuth.
Prerequisites
- For a Jira server that uses basic authentication, you have a Jira user name and password.
-
For a Jira server that uses OAuth, you have access to the
config.properties
file that contains values for the Jira access token, consumer key, private key, and verification code.
Procedure
- In Fuse Online, in the navigation panel, click Connections to display any available connections.
- In the upper right, click Create Connection to display the available connectors.
- Click the Jira connector.
In the Jira URL field, enter the URL for the Jira server that you want an integration to connect to, for example,
https://issues.mycompany.org
.For a connection to a Jira server uses OAuth, the procedure to register your Fuse Online environment as a Jira consumer application resulted in a
config.properties
file. The URL that you specify here should be the same URL that is in thatconfig.preperties
file. For example, you would see a line like this in theconfig.properties
file:jira_home=https\:issues.mycompany.org
If this Jira server uses basic authentication:
- In the User name field, enter a Jira user name. The connection uses this account to operate on the specified Jira server.
- In the Password field, enter the specified user’s password.
Skip the next step if the Jira server does not use OAuth authentication.
If the Jira server uses OAuth authentication:
-
Open the
config.properties
file that contains the OAuth access token, keys, and verification code. This is the file that is the result of the registration procedure. Copy values from that file and paste them into the connection configuration fields. -
Copy the
access_token
value into the Access Token field. -
Copy the
consumer_key
value into the Consumer Key field. -
Copy the
private_key
value into the Private Key field. -
Copy the
secret
value into the Verification Code field.
-
Open the
- Click Validate. Fuse Online displays a message that indicates whether it can validate this connection. If validation fails, try again and be sure to enter the correct values.
- When validation is successful, click Next.
-
In the Name field, enter your choice of a name that helps you distinguish this connection from any other connections. For example, enter
Jira Connect 1
. -
In the Description field, optionally enter any information that is helpful to know about this connection. For example, enter
Sample Jira connection that uses the jkim account.
- Click Save to see that the connection you created is now available. If you entered the example name, you would see that Jira Connect 1 appears as a connection that you can choose to add to an integration.
11.3. Obtaining Jira issues or comments to trigger integration execution
To trigger integration execution upon obtaining issues or comments from a Jira server, add a Jira connection as a simple integration’s start connection.
Prerequisites
- You created a Jira connection.
Procedure
- In the Fuse Online panel on the left, click Integrations.
- Click Create Integration.
- On the Choose a connection page, click the Jira connection that you want to use to start the integration.
On the Choose an action page, select an action:
- Retrieve New Comments uses a query that you specify to search the Jira server. For each issue that the query returns, the connection checks whether a comment has been added since the previous invocation of the query. The connection returns any new comments.
- Retrieve New Issues uses a query that you specify to search the Jira server. For each issue that the query returns, the connection checks its creation date. If the issue was created since the previous invocation of the query, the connection returns the issue to the integration. The first time that the connection executes this query, it returns all issues that it finds.
- In the Delay field, accept the default of 5000 milliseconds (5 seconds) or enter the number of milliseconds that you want to elapse between query invocations.
In the Jira Query Language field, enter a Jira query. For example:
project = GATE AND assignee = jkim AND (status = Open OR status = New OR status = Reopened)
This query finds issues in the Gateway Online project, that are assigned to jkim and that are unresolved. Every Jira project has a short name and a long name. In this example, the short name of the Gateway Online project is GATE. In queries, specify a project’s short name.
The more specific the query is, the less time it takes to search the Jira server. When a query does not have any results, the connection does not trigger integration execution.
- Click Next.
Result
The connection starts a simple integration and Fuse Online prompts you to choose the integration’s finish connection.
11.4. Adding an issue to a Jira server
In the middle of a flow, or to finish a simple integration, you can connect to a Jira server to add an issue.
Prerequisites
- You created a Jira connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a simple integration’s finish connection.
Procedure
- On the Add to Integration page, click the plus sign where you want to add a Jira connection. Skip this step if you are adding a simple integration’s finish connection.
- Click the Jira connection that you want the integration to use to connect to a Jira server.
- On the Choose an action page, select Add Issue.
Configure the action. The required fields are Issue type ID or name and Project key. For the optional fields, you can enter values now, or, after you add this connection to an integration, you can add a data mapper step before this connection. In the data mapper step, map fields from previous steps to the optional fields in this connection.
- Optionally, in the Assignee field, enter the Jira user name for the person that you want to assign this issue to.
- Optionally, in the Components field, enter the name of one or more components. Separate multiple names with commas. A Jira administrator defines the components that you can specify.
- Optionally, in the Priority ID or name field, enter a priority for the new issue. A Jira administrator defines the priority values that you can enter.
- Optionally, in the Summary field, enter a brief statement about the issue.
In the Issue type ID or name field, enter a value that describes the type of the issue. For example, this is often something like
Story
,Epic
,Chore
, orBug
.In Jira, a user with administrator permissions can see a list of valid issue types by selecting Project settings > Issue types. A user without these permissions can click in an issue’s type field and a list of allowable values should display.
- Optionally, in the Watchers field, enter a comma-separated list of Jira user names. These people receive notifications when this issue is updated.
-
In the Project Key field, enter the short name of a Jira project that a Jira administrator has defined. The connection creates the new issue in this project. For example, a project key is something like
GATE
. - Optionally, in the Description field, enter any information about this issue that it is helpful to capture.
- Click Next.
Result
The connection appears in the integration visualization where you added it.
11.5. Adding a comment to a Jira issue
In the middle of a flow, or to finish a simple integration, you can connect to a Jira server to add a comment to an issue.
Prerequisites
- You created a Jira connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a simple integration’s finish connection.
Procedure
- On the Add to Integration page, click the plus sign where you want to add a Jira connection. Skip this step if you are adding a simple integration’s finish connection.
- Click the Jira connection that you want the integration to use to connect to a Jira server.
- On the Choose an action page, select Add Comment.
- In the Comment field, enter the comment that you want to add to the issue or plan to add a data mapper step before this connection. In that data mapper step, map the comment from a previous integration step to this connection’s comment field.
-
In the Issue Key field, enter the Jira identifier for the issue. Examples of issue keys:
GATE-1234
,Ent-239
. - Click Next.
Result
The connection appears in the integration visualization where you added it.
Next steps
To map the comment from a previous integration step to this connection, add the connection that provides the comment content and then add a data mapper step before this Jira connection. For example, suppose a database connection obtains customer records. In the data mapper step, map the collection of customer records to the Jira connection’s comment field.
11.6. Attaching a file to a Jira issue
In the middle of a flow, or to finish a simple integration, you can connect to a Jira server to attach one or more files to an issue. In the integration, there must be a previous step that obtains the file(s) that you want to attach.
Prerequisites
- You created a Jira connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a simple integration’s finish connection.
Procedure
- On the Add to Integration page, click the plus sign where you want to add a Jira connection. Skip this step if you are adding a simple integration’s finish connection.
- Click the Jira connection that you want the integration to use to connect to the Jira server.
- On the Choose an action page, select Attach File.
-
In the Issue Key field, enter the Jira identifier of the issue that you want to attach a file to. Examples of issue keys:
GATE-1234
,Ent-239
. - Click Next.
Result
The connection appears in the integration visualization where you added it.
Next step
If the integration does not already have an earlier connection that obtains the file(s) that you want to attach to a Jira issue, add that connection to the integration. Make sure that it is before the Jira connection that attaches a file. For example, suppose you add an FTP connection and download one or more files from an FTP server. When the integration executes, the subsequent Jira connection attaches those files to the Jira issue that you specified when you configured the attach file action.
11.7. Adding and removing Jira issue watchers
In the middle of a flow, or to finish a simple integration, you can connect to a Jira server to add watchers to an issue and/or remove watchers from issue.
Prerequisites
- You created a Jira connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a simple integration’s finish connection.
Procedure
- On the Add to Integration page, click the plus sign where you want to add a Jira connection. Skip this step if you are adding a simple integration’s finish connection.
- Click the Jira connection that you want the integration to use.
- On the Choose an action page, select Add Issue.
-
In the Issue Key field, enter the Jira identifier of the issue that you want to add watchers to or remove watchers from. Examples of issue keys:
GATE-1234
,Ent-239
. - Optionally, in the Add Watchers field, enter a comma-separated list of Jira user names. These people receive notifications when this issue is updated.
- Optionally, in the Remove Watchers field, enter a comma-separated list of Jira user names that are already watching this issue. The connection removes these users from the list of watchers.
- Click Next.
Result
The connection appears in the integration visualization where you added it.
11.8. Updating an issue on a Jira server
In the middle of a flow, or to finish a simple integration, you can connect to a Jira server to update an issue. The connection can update one or more issue fields. If the issue being updated already has a value for a field, the connection replaces that value with any value you specify for the connection or that you map to a connection field. For example, if the issue already has a description, and you specify text in the Description field when you configure the Update Issue action, the connection replaces the description that was there with this new description.
Prerequisites
- You created a Jira connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a simple integration’s finish connection.
Procedure
- On the Add to Integration page, click the plus sign where you want to add a Jira connection. Skip this step if you are adding a simple integration’s finish connection.
- Click the Jira connection that you want the integration to use to connect to the Jira server.
- On the Choose an action page, select Update Issue.
Configure the action. The only required field is Issue Key. For the optional fields, you can enter values now, or, after you add this connection to an integration, you can add a data mapper step before this connection. In the data mapper step, map fields from previous steps to the optional fields in this connection.
- Optionally, in the Assignee field, enter the Jira user name for the person that you want to assign this issue to.
- Optionally, in the Components field, enter the name of one or more components. Separate multiple names with commas. A Jira administrator defines the components that you can specify.
-
In the Issue Key field, enter the Jira identifier for the issue that you want the connection to update. Examples of issue keys:
GATE-1234
,Ent-239
. - Optionally, in the Priority ID or name field, enter a priority for the new issue. A Jira administrator defines the priority values that you can enter.
- Optionally, in the Summary field, enter a brief statement about the issue.
-
In the Issue type ID or name field, enter a value that describes the type of the issue. For example, this is often something like
Story
,Epic
,Chore
, orBug
. - Optionally, in the Description field, enter any information about this issue that it is helpful to capture.
- Click Next.
Result
The connection appears in the integration visualization where you added it.
11.9. Transitioning a Jira issue to a new status
In the middle of a flow, or to finish a simple integration, you can connect to a Jira server to transition an issue to a new status, or to a new workflow stage. A Jira administrator defines what it means for an issue to transition as well as the values for transition IDs.
Prerequisites
- You created a Jira connection.
- You are creating or editing a flow and Fuse Online is prompting you to add to the integration. Or, Fuse Online is prompting you to choose a simple integration’s finish connection.
Procedure
- On the Add to Integration page, click the plus sign where you want to add a Jira connection. Skip this step if you are adding a simple integration’s finish connection.
- Click the Jira connection that you want the integration to use to connect to the Jira server.
On the Choose an action page, select Transition Issue.
You do not need to specify any values to configure the transition issue action. Instead, you can map values from previous integration steps to the fields in the this connection.
- Optionally, in the Comment field, enter a comment that you want to add to the issue.
-
Optionally, in the Issue Key field, enter the Jira identifier for the issue that is transitioning. Examples of issue keys:
GATE-1234
,Ent-239
. Optionally, in the ID of the transition field, enter an integer that a Jira administrator has associated with a particular transition, such as when a Jira moves from being new to being worked on, or when it moves from being worked on to being tested.
A Jira administrator can view transition IDs in a project’s workflow display. If you do not have administration permissions, obtain the allowed transition IDs from a Jira administrator.
- Click Next.
Result
The connection appears in the integration visualization where you added it.
Next steps
If you did not specify a value in each Transition Issue field, ensure that the integration has a step that obtains the value for each field. After the integration has all required connections, add a data mapper step before the Jira connection that transitions an issue. In the data mapper step, map fields from previous steps to the fields in the Jira connection that transitions an issue.