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:
pipeline-feedback: instana/pipeline-feedback@2.0.3
Use pipeline-feedback
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
The sample usage of the Instana Pipeline Feedback CircleCI Orb shows a workflow that includes the build and release of an application. Before the release is performed, data about the upcoming release is submitted to Instana, including CircleCI data like the build identifier and build number in the release name to be displayed in Instana. In the example, the release in Instana is scoped to the `My Awesome App` Application Perspective and, additionally, two services, `Cool service #1` and `Cool service #2`.
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
version: '2.1'
orbs:
pipeline-feedback: instana/pipeline-feedback@2.0.1
jobs:
build_payment_service:
docker:
- image: cimg/node:lts
steps:
- run: echo Build
release_payment_service:
docker:
- image: icr.io/instana/pipeline-feedback-orb-executor:latest
steps:
- pipeline-feedback/create_release:
release_name: 'My Awesome App release (CircleCI: ${CIRCLE_JOB}/${CIRCLE_BUILD_NUM})'
release_scope: |
{
"applications": [
{ "name": "My Awesome App" }
],
"services": [
{ "name": "Cool service #1" },
{ "name": "${CIRCLE_PROJECT_REPONAME}" },
{ "name": "${CIRCLE_PROJECT_REPONAME}.production" },
{ "name": "${CIRCLE_PROJECT_REPONAME}.staging" },
{ "name": "${CIRCLE_PROJECT_REPONAME}.dev" },
{
"name": "Cool service #2",
"scopedTo": {
"applications": [
{ "name": "My Cool App" }
]
}
}
]
}
- run: echo "Do a lot of release"
workflows:
build_and_release_payment_service:
jobs:
- build_payment_service
- release_payment_service:
requires:
- build_payment_service
Create a new Pipeline Feedback release in Instana.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
api_token | The name of the environment variable that contains a valid API token with the "Configuration of releases" permissions.
| No | INSTANA_API_TOKEN | env_var_name |
endpoint | The name of the environment variable that contains the URL of your Instana tenant unit, e.g.: https://apm-awesome.instana.io. For self-managed (a.k.a. on-premise) setups, you can also add the port to use, e.g.: https://instana.awesome.com:1444.
| No | INSTANA_ENDPOINT_URL | env_var_name |
executor_image | - | No | icr.io/instana/pipeline-feedback-orb-executor:latest | string |
release_name | The name of this release in Instana. | Yes | - | string |
release_scope | JSON-encoded scoping information for the release. If not provided, the release will be marked as global to your tenant unit. | No | '{}' | string |
Create a new Pipeline Feedback release in Instana.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
api_token | The name of the environment variable that contains a valid API token with the "Configuration of releases" permissions.
| No | INSTANA_API_TOKEN | env_var_name |
endpoint | The name of the environment variable that contains the URL of your Instana tenant unit, e.g.: https://apm-awesome.instana.io. For self-managed (a.k.a., on-premise) setups, you can also add the port to use, e.g.: https://instana.awesome.com:1444.
| No | INSTANA_ENDPOINT_URL | env_var_name |
release_name | The name of this release in Instana. | Yes | - | string |
release_scope | JSON-encoded scoping information for the release. The usage of environment variables is supported. Example: ```json
{
"services": [
{"name": "${CIRCLE_PROJECT_REPONAME}.${ENV}"}
]
}
``` If not provided, the release will be marked as global to your tenant unit.
| No | '{}' | string |
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
# 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: |
Create Instana Pipeline Feedback releases from your CircleCI workflows.
display:
home_url: https://www.instana.com/docs
source_url: https://www.github.com/instana/pipeline-feedback-orb
commands:
create_release:
description: |
Create a new Pipeline Feedback release in Instana.
parameters:
api_token:
default: INSTANA_API_TOKEN
description: |
The name of the environment variable that contains a valid API token with the "Configuration of releases" permissions.
type: env_var_name
endpoint:
default: INSTANA_ENDPOINT_URL
description: |
The name of the environment variable that contains the URL of your Instana tenant unit, e.g.: https://apm-awesome.instana.io. For self-managed (a.k.a., on-premise) setups, you can also add the port to use, e.g.: https://instana.awesome.com:1444.
type: env_var_name
release_name:
description: The name of this release in Instana.
type: string
release_scope:
default: '{}'
description: |
JSON-encoded scoping information for the release. The usage of environment variables is supported. Example: ```json
{
"services": [
{"name": "${CIRCLE_PROJECT_REPONAME}.${ENV}"}
]
}
``` If not provided, the release will be marked as global to your tenant unit.
type: string
steps:
- run:
command: |
#!/bin/bash
set -x
set -eo pipefail
readonly version='dev'
function create_release() {
missing_dependencies=false
if ! which curl; then
echo 'Missing dependency: The curl command is not available'
missing_dependencies=true
fi
if ! which jq; then
echo 'Missing dependency: The jq command is not available'
missing_dependencies=true
fi
if [ ${missing_dependencies} == true ]; then
echo 'Missing dependencies detected, aborting'
exit 1
fi
if [ -z "${INSTANA_RELEASE_SCOPE}" ]; then
INSTANA_RELEASE_SCOPE='{}'
fi
if which envsubst; then
release_name=$(echo "${INSTANA_RELEASE_NAME}" | envsubst)
INTERPOLATED_JSON=$(echo "${INSTANA_RELEASE_SCOPE}" | envsubst)
else
echo 'The envsubst command is not available, skipping the interpolation of environment variables in the release name and release scope'
release_name="${INSTANA_RELEASE_NAME}"
INTERPOLATED_JSON="${INSTANA_RELEASE_SCOPE}"
fi
echo "Creating release '${release_name}'"
echo "${INTERPOLATED_JSON}" > scope.json
if ! OUTPUT=$(jq empty scope.json 2>&1); then
echo "Scope JSON is invalid: ${OUTPUT}"
exit 1
fi
curl --location --request POST "${!INSTANA_ENDPOINT_URL_NAME}/api/releases" \
--silent \
--fail \
--show-error \
--header "Authorization: apiToken ${!INSTANA_API_TOKEN_NAME}" \
--header 'Content-Type: application/json' \
--user-agent "instana/pipeline-feedback-orb/${version}" \
--data "{
\"name\": \"${release_name}\",
\"start\": $(date +%s)000,
\"applications\": $(jq -r '.applications' < scope.json),
\"services\": $(jq -r '.services' < scope.json)
}" | jq -r ".id" | xargs -I {} echo "New release created with id {}"
}
create_release
environment:
INSTANA_API_TOKEN_NAME: <<parameters.api_token>>
INSTANA_ENDPOINT_URL_NAME: <<parameters.endpoint>>
INSTANA_RELEASE_NAME: <<parameters.release_name>>
INSTANA_RELEASE_SCOPE: <<parameters.release_scope>>
name: Create new release
jobs:
create_release:
description: |
Create a new Pipeline Feedback release in Instana.
docker:
- image: <<parameters.executor_image>>
parameters:
api_token:
default: INSTANA_API_TOKEN
description: |
The name of the environment variable that contains a valid API token with the "Configuration of releases" permissions.
type: env_var_name
endpoint:
default: INSTANA_ENDPOINT_URL
description: |
The name of the environment variable that contains the URL of your Instana tenant unit, e.g.: https://apm-awesome.instana.io. For self-managed (a.k.a. on-premise) setups, you can also add the port to use, e.g.: https://instana.awesome.com:1444.
type: env_var_name
executor_image:
default: icr.io/instana/pipeline-feedback-orb-executor:latest
type: string
release_name:
description: The name of this release in Instana.
type: string
release_scope:
default: '{}'
description: JSON-encoded scoping information for the release. If not provided, the release will be marked as global to your tenant unit.
type: string
steps:
- create_release:
api_token: << parameters.api_token >>
endpoint: << parameters.endpoint >>
release_name: << parameters.release_name >>
release_scope: << parameters.release_scope >>
examples:
create_release:
description: |
The sample usage of the Instana Pipeline Feedback CircleCI Orb shows a workflow that includes the build and release of an application. Before the release is performed, data about the upcoming release is submitted to Instana, including CircleCI data like the build identifier and build number in the release name to be displayed in Instana. In the example, the release in Instana is scoped to the `My Awesome App` Application Perspective and, additionally, two services, `Cool service #1` and `Cool service #2`.
usage:
version: "2.1"
orbs:
pipeline-feedback: instana/pipeline-feedback@2.0.1
jobs:
build_payment_service:
docker:
- image: cimg/node:lts
steps:
- run: echo Build
release_payment_service:
docker:
- image: icr.io/instana/pipeline-feedback-orb-executor:latest
steps:
- pipeline-feedback/create_release:
release_name: 'My Awesome App release (CircleCI: ${CIRCLE_JOB}/${CIRCLE_BUILD_NUM})'
release_scope: |
{
"applications": [
{ "name": "My Awesome App" }
],
"services": [
{ "name": "Cool service #1" },
{ "name": "${CIRCLE_PROJECT_REPONAME}" },
{ "name": "${CIRCLE_PROJECT_REPONAME}.production" },
{ "name": "${CIRCLE_PROJECT_REPONAME}.staging" },
{ "name": "${CIRCLE_PROJECT_REPONAME}.dev" },
{
"name": "Cool service #2",
"scopedTo": {
"applications": [
{ "name": "My Cool App" }
]
}
}
]
}
- run: echo "Do a lot of release"
workflows:
build_and_release_payment_service:
jobs:
- build_payment_service
- release_payment_service:
requires:
- build_payment_service