concourse-ci's lp-api-resource to interact with https://api.launchpad.net/ by using https://github.com/fourdollars/lp-api.
resource_types:
- name: lp-api
type: registry-image
source:
repository: fourdollars/lp-api-resource
defaults:
oauth_consumer_key: test
oauth_token: csjrGznX4Jq59CB8941N
oauth_token_secret: wxDNqsCLxzrmhb2K27FRGjc7hdp3zQk0b4N8cnfRzVHnJfCFlHgkGHxDk5qMPTSdQFSsllS4dwGBD18Q
or
resource_types:
- name: lp-api
type: registry-image
source:
repository: ghcr.io/fourdollars/lp-api-resource
defaults:
oauth_consumer_key: test
oauth_token: csjrGznX4Jq59CB8941N
oauth_token_secret: wxDNqsCLxzrmhb2K27FRGjc7hdp3zQk0b4N8cnfRzVHnJfCFlHgkGHxDk5qMPTSdQFSsllS4dwGBD18Q
- oauth_consumer_key: optional, choose what you like.
- oauth_token: optional, run
lp-api -key oauth_consumer_key
to get it in ~/.config/lp-api.toml. - oauth_token_secret: optional, run
lp-api -key oauth_consumer_key
to get it in ~/.config/lp-api.toml.
You need to export the proper payload content variable to make it work. https://concourse-ci.org/implementing-resource-types.html
- check: inline script (via source)
resources:
- name: bug
icon: bug-outline
type: lp-api
source:
check: |
#!/bin/bash
set -exuo pipefail
IFS=$'\n\t'
lp-api get bugs/123 > payload.json
digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
payload=$(cat <<ENDLINE
[
{
"digest": "sha256:${digest}"
}
]
ENDLINE
)
export payload
- get: inline script (via source or params)
resources:
- name: bug
icon: bug-outline
type: lp-api
check_every: 10m
source:
get: |
#!/bin/bash
set -exuo pipefail
IFS=$'\n\t'
lp-api get bugs/123 > payload.json
digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
payload=$(cat <<ENDLINE
{
"version": {
"digest": "sha256:${digest}"
},
"metadata": [
{
"name": "Bug #$(jq -r .id < payload.json)",
"value": "$(jq -r .title < payload.json | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"
}
]
}
ENDLINE
)
export payload
You need to provide one of them at least.
- put: inline script (via source or params)
- script: script file (via params)
resources:
- name: bug
icon: bug-outline
type: lp-api
check_every: 10m
source:
put: |
#!/bin/bash
set -exuo pipefail
IFS=$'\n\t'
lp-api post bugs/123 ws.op=newMessage content="New comment"
lp-api get bugs/123 > payload.json
digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
payload=$(cat <<ENDLINE
{
"version": {
"digest": "sha256:${digest}"
},
"metadata": [
{
"name": "Bug #$(jq -r .id < payload.json)",
"value": "$(jq -r .title < payload.json | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"
}
]
}
ENDLINE
)
export payload
or
jobs:
- name: check-bug
plan:
- get: bug
timeout: 1m
- task: check
timeout: 1m
config:
platform: linux
image_resource:
type: registry-image
source:
repository: fourdollars/lp-api-resource
outputs:
- name: comment
run:
path: bash
args:
- -exc
- |
mkdir -p comment
echo "Another comment" > comment/comment.log
- put: bug
timeout: 1m
params:
put: |
#!/bin/bash
set -exuo pipefail
IFS=$'\n\t'
COMMENT=$(cat comment/comment.log)
lp-api post bugs/123 ws.op=newMessage content="$COMMENT"
lp-api get bugs/123 > payload.json
digest=$(jq -S -M < payload.json | sha256sum | awk '{print $1}')
payload=$(cat <<ENDLINE
{
"version": {
"digest": "sha256:${digest}"
},
"metadata": [
{
"name": "Bug #$(jq -r .id < payload.json)",
"value": "$(jq -r .title < payload.json | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')"
}
]
}
ENDLINE
)
export payload
or
jobs:
- name: check-bug
plan:
- get: bug
timeout: 1m
- task: check
timeout: 1m
config:
platform: linux
image_resource:
type: registry-image
source:
repository: fourdollars/lp-api-resource
outputs:
- name: comment
run:
path: bash
args:
- -exc
- |
mkdir -p comment
echo "Another comment" > comment/comment.log
- get: some-script-repo
- put: bug
timeout: 1m
params:
script: some-script-repo/comment.sh