You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Consolidate rollback docs into one page
- Consolidate deployment and deploy overview pages into one page
- Clarify applications for each method along with advantages and disadvantages
- Update deploy markers page to make steps more clear
Copy file name to clipboardExpand all lines: docs/guides/modules/deploy/pages/configure-deploy-markers.adoc
+61-54Lines changed: 61 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,70 +9,72 @@ This tutorial shows how to add a deploy marker step to your workflow config. Dep
9
9
10
10
Deploy markers provide a lightweight way to log your deployments without requiring a you to install the CircleCI release agent. If you install deploy markers, as described in this guide, you will also be able to use the xref:set-up-rollbacks.adoc[CircleCI rollback feature].
11
11
12
-
For a full guide to CircleCI's deploys features and functionality, refer to the xref:set-up-circleci-deploys.adoc[Set up CircleCI deploys] guide.
12
+
For a full guide to CircleCI's deploys features and functionality, refer to the xref:deployment-overview.adoc[Deployment and deploy management] guide.
13
+
14
+
You can configure deploy markers as follows:
15
+
16
+
* To display updated statuses depending of the outcome of your deployments. Steps for this are provided in the <<deploy-markers-with-status-updates>> section.
17
+
* Or, you can choose to configure deploy markers to log deployments without status updates. Steps for this are provided in the <<deploy-logs-without-status-updates>> section.
13
18
14
19
== Prerequisites
15
20
16
21
* A CircleCI account connected to your code. You can link:https://circleci.com/signup/[sign up for free].
17
22
* A CircleCI project with a workflow configured to deploy your code.
18
23
19
-
== 1. Update the configuration
24
+
== Deploy markers with status updates
20
25
21
26
To create a deployment marker, you will update your CircleCI configuration file.
27
+
22
28
You will add commands to plan a deploy and then update its status based on the outcome of your deployment script.
23
29
30
+
NOTE: The `circleci run release` commands are only available in CircleCI builds and are not part of the CircleCI local CLI. You do not need to install the CircleCI local CLI in your CircleCI pipeline to use these commands.
31
+
24
32
=== 1.1. Plan a deploy
25
33
26
34
Add a `circleci run release plan` command to your deployment job. This tells CircleCI to plan a new deploy and show it in the link:https://app.circleci.com/deploys[Deploys UI] with `pending` status.
27
-
The `target-version` parameter should match the name of the version being deployed.
28
35
29
36
[,yml]
30
37
----
31
38
jobs:
32
39
deploy-my-service:
33
40
executor: some-executor
34
41
steps:
35
-
- run: circleci run release plan --target-version=<some-version-name>
42
+
- run: circleci run release plan <deploy-name> --environment-name=<some-environment-name> --component-name=<some-component-name> --target-version=<some-version-name> --namespace=<some-namespace>
36
43
----
37
44
38
-
If you do not have an environment set up in your organization a new one will be created with the name `default`. This will be set as the target for this deploy. See <<manage-environments>> for more information.
45
+
In this example, note the following flags and options:
46
+
47
+
* The `deploy-name` parameter is used to identify the deployment. `deploy-name` is an arbitrary positional argument that will be used to identify the deployment and should be unique within the workflow. If not specified, the deployment name will be set to `default`. If you are deploying multiple components or to multiple environments from a single workflow, you need to provide the command with a deployment name.
48
+
* The `environment-name` parameter sets the target environment. If the specified environment does not exist, it will be created. If you do not specify an environment, CircleCI will create one named `default`.
49
+
* The `component-name` parameter sets the name that will be displayed in the Deploys UI. If you do not already have a component in your project a new one will be created with the name of the project. This will be set as the component that is being deployed.
50
+
* The `target-version` parameter should match the version being deployed. Some examples are provided <<examples-for-target-version,in the next section>>.
51
+
* The `namespace` parameter is optional and can be provided to use a value other than `default`.
52
+
53
+
Configuring `circleci run release plan` identifies the deployment you are planning so that you can reference it to update its status later on.
39
54
40
-
If you do not already have a component in your project a new one will be created with the name of the project. This will be set as the component that is being deployed.
55
+
==== Examples for target-version
41
56
42
-
If you already have multiple environments and components you must specify their names manually, as follows:
57
+
This section provides some options for setting the `target-version` parameter.
43
58
59
+
* One option is to use CircleCI's built-in environment variables. For example you could define the target version as follows:
60
+
+
44
61
[,yml]
45
62
----
46
-
jobs:
47
-
deploy-my-service:
48
-
executor: some-executor
49
-
steps:
50
-
- run: circleci run release plan --environment-name=<some-environment-name> --component-name=<some-component-name> --target-version=<some-version-name> --namespace=<some-namespace>
This configuration would yield a value with the following format `1.0.28853-ffdbeb1`.
52
67
53
-
In this example, note the following:
54
-
55
-
** The `environment-name` parameter sets the target environment. If the specified environment does not exist, it will be created.
56
-
** The `component-name` parameter sets the name that will be displayed in the Deploys UI.
57
-
** The `namespace` parameter is optional and can be provided to use a value other than `default`.
58
-
59
-
If you are deploying multiple components or to multiple environments from a single workflow, you need to provide the command with a deployment name.
60
-
This identifies the deployment your are planning so that you can later on reference it to update its status.
61
-
This can be done as shown below:
62
-
68
+
* Another option is to use pipeline values. For example you could define the target version as follows:
69
+
+
63
70
[,yml]
64
71
----
65
-
jobs:
66
-
deploy-my-service:
67
-
executor: some-executor
68
-
steps:
69
-
- run: circleci run release plan <deploy-name> --environment-name=<some-environment-name> --component-name<=>some-component-name> --target-version=<some-version-name>
72
+
--target-version=<< pipeline.number >>
70
73
----
74
+
+
75
+
This configuration would yield a value with the following format `12345`.
71
76
72
-
In the example the positional argument `deploy-name` is the arbitrary value that will be used to identify the deployment and should be unique within the workflow.
73
-
If not specified, the deployment name will be set to `default`.
74
-
75
-
=== 1.2. Update the deploy status
77
+
=== 1.2. Update the deploy status to running
76
78
77
79
After deploying your application, you can update the status of the deployment to `RUNNING` by running the `circleci run release update` command in a new step.
78
80
@@ -88,8 +90,7 @@ jobs:
88
90
- run: circleci run release update --status=running
89
91
----
90
92
91
-
If you are deploying multiple components or to multiple environments from a single workflow, you need to provide the command with a deployment name.
92
-
This value should match the value you provided when you planned the deploy.
93
+
If you are deploying multiple components or to multiple environments from a single workflow, you need to provide the command with a deployment name. The deploy name value should match the value you provided when you planned the deploy.
93
94
94
95
[,yml]
95
96
----
@@ -103,8 +104,10 @@ jobs:
103
104
- run: circleci run release update <deploy-name> --status=running
104
105
----
105
106
106
-
Now you can use the `when` attribute to add `on_success` and `on_failure` steps at the end of your deployment job, to handle the final status update of the deploy.
107
+
=== 1.3. Update the deploy status to success or failure
108
+
You can use the `when` attribute to add `on_success` and `on_failure` steps at the end of your deployment job, to handle the final status update of the deploy.
107
109
110
+
.Config file example showing deploy status update to success or failure
108
111
[,yml]
109
112
----
110
113
jobs:
@@ -132,21 +135,23 @@ jobs:
132
135
when: on_fail
133
136
----
134
137
135
-
This will update the status of the deploy to `SUCCESS` or `FAILED` depending on the outcome of your job.
136
-
In this example, the `failure_reason.env` file can be created by a previous step in the job. This can be done, for example, in a step in which we are validating the status of the deployment.
137
-
You can do that as shown below:
138
+
In this example, the status of the deploy is updated to `SUCCESS` or `FAILED` depending on the outcome of your job.
139
+
140
+
The `failure_reason.env` file can be created by a previous step in the job. This can be done, for example, in a step in which we are validating the status of the deployment. One way to do this is as follows:
138
141
142
+
.Create a file to store the failure reason
139
143
[,yml]
140
144
----
141
145
echo "FAILURE_REASON='Deployment was not found'" > failure_reason.env
142
146
----
143
147
144
148
CAUTION: Trying to update the status of the deploy after updating it to a terminal status such as `SUCCESS`, `FAILED` or `CANCELED` is not supported and will result in an error.
145
149
146
-
=== 1.3 Update the deploy status to canceled
150
+
=== 1.4 Update the deploy status to canceled
147
151
148
152
If you want to update your deployment to `canceled` when the deploy job is canceled, you can do so by adding the following job to your configuration.
149
153
154
+
.Job configuration for updating the deploy status to canceled
150
155
[,yml]
151
156
----
152
157
jobs:
@@ -166,6 +171,7 @@ jobs:
166
171
167
172
Then you can add it to your workflow as shown below.
168
173
174
+
.Workflow configuration for updating the deploy status to canceled. The cancel-deploy job only runs when the deploy job is canceled
169
175
[,yml]
170
176
----
171
177
workflows:
@@ -178,9 +184,9 @@ workflows:
178
184
- canceled
179
185
----
180
186
181
-
This will make it sot that the job will be run only when the `deploy` job is canceled, thus updating the deployment to the `canceled` status.
187
+
In this example, the `cancel-deploy` job will be run only when the `deploy` job is canceled, thus updating the deployment to the `canceled` status.
182
188
183
-
=== 1.4. Full config example
189
+
=== 1.5. Full config example
184
190
185
191
For reference, here is a full example of a CircleCI config that makes use of the deployment tracking feature.
186
192
@@ -239,7 +245,7 @@ workflows:
239
245
- canceled
240
246
----
241
247
242
-
== 2. Deploy logs
248
+
== Deploy logs without status updates
243
249
244
250
Sometimes you might not want your deployment marker to have any specific status, but still want it to be logged in the deploys UI.
245
251
In those cases you can use the `release log` command in place of `release plan` as shown in the example below.
@@ -273,29 +279,30 @@ jobs:
273
279
274
280
** The `environment-name` specifies the target environment. If the environment does not exist, it will be created.
275
281
** The `component-name` parameter sets the name that will be displayed in the CircleCI UI.
276
-
** The `target-version` parameter should match the name of the version being deployed.
282
+
** The `target-version` parameter should match the name of the version being deployed. Some examples are provided <<examples-for-target-version,above>>.
277
283
** (Optional) You can provide the following parameter if required:
278
284
*** The `namespace` parameter can be provided to use a value other than `default`.
279
285
280
-
[#manage-environments]
281
-
== 3. Manage environments
286
+
== Manage environments
287
+
288
+
In this guide we created an environment integration by supplying a name with the `--envionment-name` flag. This was an optional step. If you did not specify an environment CircleCI will have created one for you with the name `default`.
289
+
290
+
You can also create an environment integration manually in the CircleCI web app.
282
291
283
-
Configuring deploy markers will automatically create an environment integration in the link:https://app.circleci.com/deploys[CircleCI deploys UI] with the name you specified or with the `default` name if you didn't specify any.
284
-
You can then use the link:https://app.circleci.com/deploys/github/circleci#environments[CircleCI UI] to manage your environments, by creating, deleting or updating them.
285
-
To manually create an environment integration, follow these steps:
292
+
=== Create an environment integration
286
293
287
-
. In the CircleCI web app, select **Deploys** in the sidebar.
288
-
. If this is your first environment setup, select btn:[Create your first Environment Integration]. If you already have environments set up, choose the **Environments** tab and select btn:[Create Environment Integration].
294
+
. In the link:https://app.circleci.com[CircleCI web app], select your org from the org cards on your user homepage.
295
+
. Select **Deploys** in the sidebar.
296
+
. Select the **Environments** tab.
297
+
. Select btn:[Create Environment Integration].
289
298
. Enter a name for your environment, and a description if you would like.
290
-
. Use the dropdown menu to choose your environment integration type, then select btn:[Next: Release Agent Setup].
291
-
If you plan to only use deploy markers, as opposed to the Kubernetes agent, feel free to choose the `custom` type.
292
-
**You do not need to continue with installing a release agent at this point**, but you will need to reference this environment integration name as part of your config when adding the `log release` step below.
299
+
. Use the dropdown menu to choose your environment integration type. Choose the "Custom" option to follow along with this guide,. If you are deploying to your Kubernetes cluster you can or if you want to use the CircleCI release agent, then choose "Kubernetes Cluster" and head over to the xref:set-up-circleci-deploys.adoc[Release agent setup] page.
300
+
. Select btn:[Save and Continue].
293
301
294
302
== Next steps
295
303
296
304
By following the steps in this guide, you have added a deploy marker to your CircleCI configuration.
297
305
You can now track the status of your deployments across your configured environments in the CircleCI deploys UI and in the project home page.
298
306
You can now:
299
307
300
-
* xref:set-up-the-release-agent.adoc[Set up a release agent on your Kubernetes cluster].
301
-
* xref:configure-deploy-markers.adoc[Learn about deploy markers]
0 commit comments