Skip to content

fourdollars/jira-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub: fourdollars/jira-resource License: MIT Bash Docker Docker Pulls

jira-resource

Concourse CI's Jira resource to interact with Jira REST APIs.

Config

Resource Type

resource_types:
- name: jira
  type: registry-image
  source:
    repository: fourdollars/jira-resource
    tag: latest

or

resource_types:
- name: jira
  type: registry-image
  source:
    repository: ghcr.io/fourdollars/jira-resource
    tag: latest

Resource

  • url: Required
  • user: Required
  • token: Required
  • resource: Required
resources:
- name: issue
  icon: jira
  type: jira
  check_every: 15m
  source:
    url: https://jira.atlassian.com/rest/api/latest/
    user: username
    token: password
    resource: issue/JRA-9
- name: search-by-label
  icon: jira
  type: jira
  check_every: 15m
  source:
    url: https://jira.atlassian.com/rest/api/latest/
    user: username
    token: password
    resource: "search?jql=project=DEVOPS%20AND%20labels%20IN%20(\"Concourse-CI\")&maxResults=50"
- name: search-by-label
  icon: jira
  type: jira
  check_every: 15m
  source:
    url: https://jira.atlassian.com/rest/api/latest/
    user: username
    token: password
    resource: "search?jql=project=DEVOPS%20AND%20labels%20IN%20(\"Concourse-CI\")&maxResults=50"
- name: all-issues
  icon: jira
  type: jira
  check_every: 15m
  source:
    url: https://jira.atlassian.com/rest/api/latest/
    user: username
    token: password
    fetch: issues
    resource: "search?jql=project=DEVOPS"

check step

  - get: issue
    trigger: true
# It acts like the following commands.
$ curl -fsSL --user "username:password" https://jira.atlassian.com/rest/api/latest/issue/JRA-9 > payload.json
$ digest="sha256:$(jq -S -M < payload.json | sha256sum | awk '{print $1}')"

get step

  - get: issue
    trigger: true
# It acts like the following commands.
$ cd /tmp/build/get
$ curl -fsSL --user "username:password" https://jira.atlassian.com/rest/api/latest/issue/JRA-9 > payload.json

put step

  - put: issue
    params:
      json: output/data.json
# It acts like the following commands.
$ cd /tmp/build/put
$ curl -fsSL --user "username:password" -X PUT --data @output/data.json -H "Content-Type: application/json" https://jira.atlassian.com/rest/api/latest/issue/JRA-9 > payload.json

Job Example

jobs:
- name: check-jira-issue
  plan:
  - get: issue
    trigger: true
  - task: check
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: alpine
          tag: latest
      inputs:
        - name: issue
      run:
        path: sh
        args:
        - -exc
        - |
          apk add --quiet --no-progress jq
          jq -r .self < issue/payload.json
- name: check-jira-search
  plan:
  - get: search-by-label
    trigger: true
  - task: check
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: alpine
          tag: latest
      inputs:
        - name: search-by-label
      run:
        path: sh
        args:
        - -exc
        - |
          apk add --quiet --no-progress jq
          jq -r ".issues | .[] | .self, .key, .fields.summary" < search-by-label/payload.json
- name: check-all-issues
  plan:
  - get: all-issues
    trigger: true
  - task: check
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: alpine
          tag: latest
      inputs:
        - name: all-issues
      run:
        path: sh
        args:
        - -exc
        - |
          apk add --quiet --no-progress jq
          jq -r ".issues | .[] | .self, .key, .fields.summary" < all-issues/payload.json
- name: comment-on-jira-issue
  plan:
  - get: issue
  - task: comment
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: alpine
          tag: latest
      inputs:
        - name: issue
      outputs:
        - name: output
      run:
        path: sh
        args:
        - -exc
        - |
          apk add --quiet --no-progress jq
          SELF=$(jq -r .self < issue/payload.json)
          mkdir -p output
          cat > output/data.json <<ENDLINE
          {
            "update": {
              "comment": [
                {
                  "add": {
                    "body": "The self link of this issue is $SELF."
                  }
                }
              ]
            }
          }
          ENDLINE
  - put: issue
    params:
      json: output/data.json