Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
webhook: pmbot/webhook@1.1.0
Use webhook
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Use this webhook to send notifications to our backend. See our docs here: https://docs.pmbot.io/ci-providers/circle-ci. This orb needs to be used on every job that your .circle/config.yml file contains. The orb makes a simple HTTP request to Pmbot server to notify when a job ends. Pmbot can then check the status of your pipeline and determine whether the update of your dependency failed. The orb uses various environment variables named PMBOT_... that are configured automatically by Pmbot when you setup a repository. These variables are used by our orb to authenticate the webhook call. Additionally, it uses both environment variables PMBOT_UPDATE_ID and PMBOT_SSH_PRIVATE_KEY, configured as pipeline parameters and sent by Pmbot when triggering pipelines when your automated updates are scheduled.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
version: '2.1'
orbs:
pmbot: pmbot/webhook@0.1.0
jobs:
test:
docker:
- image: alpine
steps:
- pmbot/webhook
update:
docker:
- image: pmbot/bot
environment:
PMBOT_SSH_PRIVATE_KEY: << pipeline.parameters.PMBOT_SSH_PRIVATE_KEY >>
PMBOT_UPDATE_ID: << pipeline.parameters.PMBOT_UPDATE_ID >>
steps:
- checkout
- run:
command: |
# install dependencies for the npm plugin
npm ci
pmbot update
- pmbot/webhook
workflows:
main:
jobs:
- test
unless: << pipeline.parameters.PMBOT >>
update:
jobs:
- update
when: << pipeline.parameters.PMBOT >>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Notify Pmbot of your jobs statuses. Pmbot will use this to automatically update your dependencies so you can develop faster, more security and more efficiently.
display:
home_url: https://www.pmbot.io
source_url: https://github.com/pmbot-io/circleci-webhook-orb
commands:
webhook:
description: Send job statuses to Pmbot
steps:
- run:
command: |
# install curl if needed
if ! command -v curl &> /dev/null
then
# alpine
if command -v apk &> /dev/null
then
apk add curl
fi
# debian
if command -v apt-get &> /dev/null
then
apt-get install curl
fi
fi
# send webhook
# PMBOT_TOKEN is defined by our backend
curl \
-H "Content-Type: application/json" \
-H "Pmbot-Token: $PMBOT_TOKEN" \
--request POST \
--data "{\"build_num\":$CIRCLE_BUILD_NUM,\"build_url\":\"$CIRCLE_BUILD_URL\"}" \
"$PMBOT_URL/api/v1/repos/$PMBOT_REPO_ID/pipelines"
when: always
examples:
send_job_status_to_pmbot:
description: |
Use this webhook to send notifications to our backend. See our docs here: https://docs.pmbot.io/ci-providers/circle-ci.
This orb needs to be used on every job that your .circle/config.yml file contains.
The orb makes a simple HTTP request to Pmbot server to notify when a job ends. Pmbot can then check the status of your pipeline and determine whether the update of your dependency failed. The orb uses various environment variables named PMBOT_... that are configured automatically by Pmbot when you setup a repository. These variables are used by our orb to authenticate the webhook call.
Additionally, it uses both environment variables PMBOT_UPDATE_ID and PMBOT_SSH_PRIVATE_KEY, configured as pipeline parameters and sent by Pmbot when triggering pipelines when your automated updates are scheduled.
usage:
version: "2.1"
orbs:
pmbot: pmbot/webhook@0.1.0
jobs:
test:
docker:
- image: alpine
steps:
- pmbot/webhook
update:
docker:
- image: pmbot/bot
environment:
PMBOT_SSH_PRIVATE_KEY: << pipeline.parameters.PMBOT_SSH_PRIVATE_KEY >>
PMBOT_UPDATE_ID: << pipeline.parameters.PMBOT_UPDATE_ID >>
steps:
- checkout
- run:
command: |
# install dependencies for the npm plugin
npm ci
pmbot update
- pmbot/webhook
workflows:
main:
jobs:
- test
unless: << pipeline.parameters.PMBOT >>
update:
jobs:
- update
when: << pipeline.parameters.PMBOT >>