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:
agent: blackfireio/agent@1.2.0
Use agent
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
Easily install and configure the Blackfire agent
1
2
3
4
5
6
7
8
9
10
version: 2.1
orbs:
blackfire-agent: blackfireio/agent@x.y
jobs:
blackfire-agent-example:
docker:
- image: circleci/php:7.3-node
steps:
- checkout
- blackfire-agent/setup
Trigger a Blackfire build as described in https://blackfire.io/docs/reference-guide/builds-and-integrations
1
2
3
4
5
6
7
8
9
10
11
12
13
version: 2.1
orbs:
blackfire-agent: blackfireio/agent@x.y
jobs:
blackfire-build-example:
docker:
- image: circleci/php:7.4-node
steps:
- checkout
- blackfire-agent/build-trigger:
endpoint: https://staging.my-webapp.tld/
environment: My Blackfire Environment Name
token: ${BLACKFIRE_BUILD_TOKEN}
Registers Blackfire agent and CLI tool with your credentials passed as environment variables.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
server_id | Environment variable name in which your server ID is stored. | No | BLACKFIRE_SERVER_ID | env_var_name |
server_token | Environment variable name in which your server token is stored. | No | BLACKFIRE_SERVER_TOKEN | env_var_name |
client_id | Environment variable name in which your client ID is stored. | No | BLACKFIRE_CLIENT_ID | env_var_name |
client_token | Environment variable name in which your client token is stored. | No | BLACKFIRE_CLIENT_TOKEN | env_var_name |
Installs and configures Blackfire agent. setup command MUST BE CALLED BEFORE.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
server_id | Environment variable name in which your server ID is stored. | No | BLACKFIRE_SERVER_ID | env_var_name |
server_token | Environment variable name in which your server token is stored. | No | BLACKFIRE_SERVER_TOKEN | env_var_name |
client_id | Environment variable name in which your client ID is stored. | No | BLACKFIRE_CLIENT_ID | env_var_name |
client_token | Environment variable name in which your client token is stored. | No | BLACKFIRE_CLIENT_TOKEN | env_var_name |
Installs and configures Blackfire agent in a RedHat environment.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
server_id | Environment variable name in which your server ID is stored. | No | BLACKFIRE_SERVER_ID | env_var_name |
server_token | Environment variable name in which your server token is stored. | No | BLACKFIRE_SERVER_TOKEN | env_var_name |
client_id | Environment variable name in which your client ID is stored. | No | BLACKFIRE_CLIENT_ID | env_var_name |
client_token | Environment variable name in which your client token is stored. | No | BLACKFIRE_CLIENT_TOKEN | env_var_name |
Triggers a Blackfire build using a webhook.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
endpoint | Endpoint for reaching your application out. | Yes | - | string |
environment | Environment name or UUID on which the build is triggered.
Part of the environment name can be used.
| Yes | - | string |
token | Build Token to use for the build.
More information at https://blackfire.io/docs/cookbooks/builds/builds-webhook#build-tokens
It is strongly recommended to use a project environment variable and use it to fill this parameter.
| Yes | - | string |
title | Title of the triggered build. | No | CircleCI '${CIRCLE_JOB}' ${CIRCLE_BUILD_NUM} | string |
external-id | A unique identifier for the build. Defaults to the latest git commit sha1. | No | ${CIRCLE_SHA1} | string |
external-parent-id | The unique identifier of the parent build, to compare with the current build, like the reference Git commit sha1. | No | '' | string |
external-url | A URL related to the build, like a Pull Request. | No | ${CIRCLE_BUILD_URL} | string |
http-username | The username for HTTP Basic authentication on the endpoint. | No | '' | string |
http-password | The password for HTTP Basic authentication on the endpoint. | No | '' | string |
ip | The IP for forcing DNS. | No | '' | string |
ssl-no-verify | If true, disables SSL certificates verification (this is insecure) | No | false | boolean |
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# 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: |
This orb installs and configures Blackfire agent and CLI tool.
You need an account on https://blackfire.io to use this orb.
Blackfire is the Code Performance Management solution for developers
to find and fix performance bottlenecks in dev, test/staging and production.
The "agent" is the component that aggregates profile data collected by the probe from your application engine
(PHP, Python...), before sending it to Blackfire.io servers so that you can display and analyze it.
display:
home_url: https://blackfire.io/
source_url: https://github.com/blackfireio/integration-circleci
commands:
register:
description: Registers Blackfire agent and CLI tool with your credentials passed as environment variables.
parameters:
server_id:
description: Environment variable name in which your server ID is stored.
type: env_var_name
default: BLACKFIRE_SERVER_ID
server_token:
description: Environment variable name in which your server token is stored.
type: env_var_name
default: BLACKFIRE_SERVER_TOKEN
client_id:
description: Environment variable name in which your client ID is stored.
type: env_var_name
default: BLACKFIRE_CLIENT_ID
client_token:
description: Environment variable name in which your client token is stored.
type: env_var_name
default: BLACKFIRE_CLIENT_TOKEN
steps:
- run:
name: 'Blackfire: Sanity checks'
command: |
function test_env_var {
if [ -z "$(printenv $1)" ]; then
echo "Error: ${1} is empty. Please ensure the environment variable ${1} has been added."
exit 1
fi
}
test_env_var << parameters.server_id >>
test_env_var << parameters.server_token >>
test_env_var << parameters.client_id >>
test_env_var << parameters.client_token >>
- run:
name: 'Blackfire: Register agent and client'
command: |
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
$SUDO blackfire-agent -register \
--server-id=${<< parameters.server_id >>} \
--server-token=${<< parameters.server_token >>}
$SUDO /etc/init.d/blackfire-agent restart
blackfire config \
--client-id=${<< parameters.client_id >>} \
--client-token=${<< parameters.client_token >>}
setup:
description: |
Installs and configures Blackfire agent.
setup command MUST BE CALLED BEFORE.
parameters:
server_id:
description: Environment variable name in which your server ID is stored.
type: env_var_name
default: BLACKFIRE_SERVER_ID
server_token:
description: Environment variable name in which your server token is stored.
type: env_var_name
default: BLACKFIRE_SERVER_TOKEN
client_id:
description: Environment variable name in which your client ID is stored.
type: env_var_name
default: BLACKFIRE_CLIENT_ID
client_token:
description: Environment variable name in which your client token is stored.
type: env_var_name
default: BLACKFIRE_CLIENT_TOKEN
steps:
- run:
name: 'Blackfire: Install Debian package'
command: |
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
wget -q -O - https://packages.blackfire.io/gpg.key | $SUDO apt-key add -
echo "deb http://packages.blackfire.io/debian any main" | $SUDO tee /etc/apt/sources.list.d/blackfire.list
$SUDO apt update
$SUDO apt-get install blackfire-agent
echo ""
blackfire-agent -v
blackfire version
- register:
server_id: << parameters.server_id >>
server_token: << parameters.server_token >>
client_id: << parameters.client_id >>
client_token: << parameters.client_token >>
setup-redhat:
description: Installs and configures Blackfire agent in a RedHat environment.
parameters:
server_id:
description: Environment variable name in which your server ID is stored.
type: env_var_name
default: BLACKFIRE_SERVER_ID
server_token:
description: Environment variable name in which your server token is stored.
type: env_var_name
default: BLACKFIRE_SERVER_TOKEN
client_id:
description: Environment variable name in which your client ID is stored.
type: env_var_name
default: BLACKFIRE_CLIENT_ID
client_token:
description: Environment variable name in which your client token is stored.
type: env_var_name
default: BLACKFIRE_CLIENT_TOKEN
steps:
- run:
name: 'Blackfire: Install RedHat package'
command: |
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
$SUDO yum install pygpgme
wget -O - "http://packages.blackfire.io/fedora/blackfire.repo" | $SUDO tee /etc/yum.repos.d/blackfire.repo
$SUDO yum install blackfire-agent
echo "\n"
blackfire-agent -v
blackfire version
- register:
server_id: << parameters.server_id >>
server_token: << parameters.server_token >>
client_id: << parameters.client_id >>
client_token: << parameters.client_token >>
build-trigger:
description: Triggers a Blackfire build using a webhook.
parameters:
endpoint:
description: Endpoint for reaching your application out.
type: string
environment:
description: |
Environment name or UUID on which the build is triggered.
Part of the environment name can be used.
type: string
token:
description: |
Build Token to use for the build.
More information at https://blackfire.io/docs/cookbooks/builds/builds-webhook#build-tokens
It is strongly recommended to use a project environment variable and use it to fill this parameter.
type: string
title:
description: Title of the triggered build.
type: string
default: "CircleCI '${CIRCLE_JOB}' ${CIRCLE_BUILD_NUM}"
external-id:
description: A unique identifier for the build. Defaults to the latest git commit sha1.
type: string
default: "${CIRCLE_SHA1}"
external-parent-id:
description: The unique identifier of the parent build, to compare with the current build, like the reference Git commit sha1.
type: string
default: ""
external-url:
description: A URL related to the build, like a Pull Request.
type: string
default: "${CIRCLE_BUILD_URL}"
http-username:
description: The username for HTTP Basic authentication on the endpoint.
type: string
default: ""
http-password:
description: The password for HTTP Basic authentication on the endpoint.
type: string
default: ""
ip:
description: The IP for forcing DNS.
type: string
default: ""
ssl-no-verify:
description: If true, disables SSL certificates verification (this is insecure)
type: boolean
default: false
steps:
- run:
name: "Blackfire: Triggering a build"
command: |
if [ -n "<<parameters.external-parent-id>>" ]; then BF_EXTERNAL_PARENT_ID="--external-parent-id=<<parameters.external-parent-id>>"; else BF_EXTERNAL_PARENT_ID=""; fi;
if [ -n "<<parameters.http-username>>" ]; then BF_HTTP_USERNAME="--http-username=<<parameters.http-username>>"; else BF_HTTP_USERNAME=""; fi;
if [ -n "<<parameters.http-password>>" ]; then BF_HTTP_PASSWORD="--http-password=<<parameters.http-password>>"; else BF_HTTP_PASSWORD=""; fi;
if [ -n "<<parameters.ip>>" ]; then BF_IP="--ip=<<parameters.ip>>"; else BF_IP=""; fi;
if [ "<<parameters.ssl-no-verify>>" == "true" ]; then BF_SSL_NO_VERIFY="--ssl-no-verify"; else BF_SSL_NO_VERIFY=""; fi;
blackfire build-trigger \
<< parameters.endpoint >> \
--env=<< parameters.environment >> \
--token=<<parameters.token>> \
--title="<< parameters.title >>" \
--external-id="<< parameters.external-id >>" \
--external-url=<< parameters.external-url >> \
$BF_TOKEN $BF_EXTERNAL_PARENT_ID $BF_HTTP_USERNAME $BF_HTTP_PASSWORD $BF_IP $BF_SSL_NO_VERIFY;
examples:
install_agent:
description: Easily install and configure the Blackfire agent
usage:
version: 2.1
orbs:
blackfire-agent: blackfireio/agent@x.y
jobs:
blackfire-agent-example:
docker:
- image: circleci/php:7.3-node
steps:
- checkout
- blackfire-agent/setup
build_trigger:
description: Trigger a Blackfire build as described in https://blackfire.io/docs/reference-guide/builds-and-integrations
usage:
version: 2.1
orbs:
blackfire-agent: blackfireio/agent@x.y
jobs:
blackfire-build-example:
docker:
- image: circleci/php:7.4-node
steps:
- checkout
- blackfire-agent/build-trigger:
endpoint: "https://staging.my-webapp.tld/"
# Blackfire Environment name or UUID
environment: My Blackfire Environment Name
# Use build token stored in BLACKFIRE_BUILD_TOKEN environment variable
# See https://blackfire.io/docs/cookbooks/builds/builds-webhook#build-tokens
token: ${BLACKFIRE_BUILD_TOKEN}