Creating links on Jira issues using OSLC services

The process to create an OSLC link on a Jira issue is the following:

  1. Execute a GET request on the Jira issue OSLC URL to obtain the current content of the resource.
  2. Modify in memory the content of the issue to add a new link to a target resource.
  3. Execute a PUT request on the Jira issue OSLC URL to inject the new content.

This page provides guidance on how to add a unidirectional link from a Jira issue to a remote OSLC resource. The same process is to apply to create the reverse link in the remote OSLC resource to target the Jira issue.

To execute those REST requests, you are free to use the REST library of your choice. You may use the MDAccess for OSLC library to ease the execution of requests, as demonstrated in Running OSLC snippets on Jira section.

GET the resource

Here is the REST request to obtain the Jira issue as an OSLC resource:

<rdf:RDF 
  ...
  <rdf:Description rdf:about="https://SERVER:PORT/rest/oslc/1.0/cm/issue/ISSUE">
    <dcterms:title rdf:parseType="Literal">Test</dcterms:title>
    <rdf:type rdf:resource="http://atlassian.com/ns/cm#Issue"/>
    <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/>
    ...
  </rdf:Description>
</rdf:RDF>

Modify the resource content in memory

The intent is now to add a link targeting an OSLC remote resource in this XML content.

If for example the Jira issue is to implement a requirement, the link type to use is http://open-services.net/ns/cm#implementsRequirement and the new resource content should be something like:

<rdf:RDF 
  ...
  <rdf:Description rdf:about="https://SERVER:PORT/rest/oslc/1.0/cm/issue/ISSUE">
    <dcterms:title rdf:parseType="Literal">Test</dcterms:title>
    <rdf:type rdf:resource="http://open-services.net/ns/cm#ChangeRequest"/>
    ...
    <oslc_cm:implementsRequirement rdf:resource="https://REMOTE-SERVER:REMOTE-PORT/myRemoteApp/myRequirement/IDENTIFIER"/>
    ...
  </rdf:Description>
</rdf:RDF>

Refer to the Links across OSLC domains section for details on link types.

PUT the resource

Here is the REST request to update the content of the Jira issue: