Skip to content

Exposing version of a resource over a HTTP endpoint and parsing via JQ into Concourse jobs. https://hub.docker.com/r/qudini/concourse-http-jq-resource

License

Notifications You must be signed in to change notification settings

qudini/concourse-http-jq-resource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Concourse HTTP jq resource

A Concourse resource to make HTTP calls to JSON endpoints, and parse them using custom JQ filter.

Source Configuration

Parameter Required Example Description
base_url Yes https://api.github.com/users/octocat/orgs Url for the json payload to get.
jq_filter No {user, title: .titles[]} Valid JQ filter. Defaults to ".". The output of JQ filter needs to be vaild JSON.
credentials No root:hunter2 Basic auth. Will be base64 encoded.
headers No ["Cookie: UserName=Bob"] an array containing headers, in "Name: Value" format.

Notes:

Behaviour

check

Produces new versions from a JSON payload defined in base_url. jq_filter then parses the payload accordingly to your needs.

get

Does nothing.

put

Does nothing.

Examples

Check deployment version on Bamboo

Triggering a job in concourse based on a release in bamboo.

resource_types:
- name: http-jq-resource
  type: docker-image
  source:
    repository: qudini/concourse-http-jq-resource
    tag: latest

resources:
  - name: bamboo-staging-release
    type: http-jq-resource
    source:
      base_url: https://<Bamboo instance>/rest/api/latest/deploy/environment/{env_id}/results?os_authType=basic
      jq_filter: "{.results[] | {"deploymentVersionName":.deploymentVersionName,"id":.id|tostring,"key":.deploymentVersion.items[0].planResultKey.key,"startedDate":.startedDate|tostring,finishedDate:.finishedDate|tostring}"
      # bamboo_readonly_credentials = username:password
      credentials: ((bamboo_readonly_credentials))

Results in

[
    {
      "deploymentVersionName": "master-718",
      "id": "107282481",
      "key": "KEY-QD678-718",
      "startedDate": "1579089918295",
      "finishedDate": "1579090971755"
    },
    {
      "deploymentVersionName": "master-717",
      "id": "107282475",
      "key": "KEY-QD678-717",
      "startedDate": "1579027585024",
      "finishedDate": "1579028083334"
    }
]

Check Docker Hub for new docker image tag to trigger a job

resource_types:
- name: http-jq-resource
  type: docker-image
  source:
    repository: qudini/concourse-http-jq-resource
    tag: latest

resources:
  - name: dockerhub-http-jq-release
    type: http-jq-resource
    source:
      base_url: https://registry.hub.docker.com/v1/repositories/qudini/concourse-http-jq-resource/tags
      jq_filter: ".[] | {releaseTag:.name}"

Results in

screenshot of resource with release tags