Skip to content

Commit 793af17

Browse files
committed
add target version and rollback config examples
1 parent a53f57a commit 793af17

File tree

2 files changed

+386
-53
lines changed

2 files changed

+386
-53
lines changed

docs/guides/modules/deploy/pages/configure-deploy-markers.adoc

Lines changed: 44 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,83 +16,58 @@ For a full guide to CircleCI's deploys features and functionality, refer to the
1616
* A CircleCI account connected to your code. You can link:https://circleci.com/signup/[sign up for free].
1717
* A CircleCI project with a workflow configured to deploy your code.
1818

19-
== 1. Create an envrionment
20-
21-
Our first step is to create an environment and component for your deployment. You can choose to skip this step if either of the following is true:
22-
23-
* You already have an environment set up in your organization.
24-
* You are happy for CircleCI to automatically create an environment with the name `default` and a component with the name of your project.
25-
26-
=== 1.1 Create an environment integration
27-
28-
. In the link:https://app.circleci.com[CircleCI web app], select your org from the org cards on your user homepage.
29-
. Select **Deploys** in the sidebar.
30-
. Select the **Environments** tab.
31-
. Select btn:[Create Environment Integration].
32-
. Enter a name for your environment, and a description if you would like.
33-
. 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.
34-
. Select btn:[Save and Continue].
35-
36-
=== 1.2
37-
38-
== 2. Update the configuration
19+
== 1. Update the configuration
3920

4021
To create a deployment marker, you will update your CircleCI configuration file.
22+
4123
You will add commands to plan a deploy and then update its status based on the outcome of your deployment script.
4224

43-
=== 2.1. Plan a deploy
25+
=== 1.1. Plan a deploy
4426

4527
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.
4628

47-
The `target-version` parameter should match the version being deployed.
48-
4929
[,yml]
5030
----
5131
jobs:
5232
deploy-my-service:
5333
executor: some-executor
5434
steps:
55-
- run: circleci run release plan --target-version=<some-version-name>
35+
- 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>
5636
----
5737

58-
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.
38+
In this example, note the following flags and options:
39+
40+
* 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.
41+
* 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`.
42+
* 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.
43+
* The `target-version` parameter should match the version being deployed. Some examples are provided <<examples-for-target-version,in the next section>>.
44+
* The `namespace` parameter is optional and can be provided to use a value other than `default`.
5945

60-
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.
46+
Configuring `circleci run release plan` identifies the deployment you are planning so that you can reference it to update its status later on.
6147

62-
If you already have multiple environments and components you must specify their names manually, as follows:
48+
==== Examples for target-version
6349

50+
This section provides some options for setting the `target-version` parameter.
51+
52+
* One option is to use CircleCI's built-in environment variables. For example you could define the target version as follows:
53+
+
6454
[,yml]
6555
----
66-
jobs:
67-
deploy-my-service:
68-
executor: some-executor
69-
steps:
70-
- 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>
56+
--target-version="1.0.${CIRCLE_BUILD_NUM}-${CIRCLE_SHA1:0:7}"
7157
----
58+
+
59+
This configuraiton would yield a value with the following format `1.0.28853-ffdbeb1`.
7260

73-
In this example, note the following:
74-
75-
** The `environment-name` parameter sets the target environment. If the specified environment does not exist, it will be created and named `default`.
76-
** The `component-name` parameter sets the name that will be displayed in the Deploys UI.
77-
** The `namespace` parameter is optional and can be provided to use a value other than `default`.
78-
79-
If you are deploying multiple components or to multiple environments from a single workflow, you need to provide the command with a deployment name.
80-
This identifies the deployment your are planning so that you can later on reference it to update its status.
81-
This can be done as shown below:
82-
61+
* Anothe option is to use pipeline values. For example you could define the target version as follows:
62+
+
8363
[,yml]
8464
----
85-
jobs:
86-
deploy-my-service:
87-
executor: some-executor
88-
steps:
89-
- run: circleci run release plan <deploy-name> --environment-name=<some-environment-name> --component-name<=>some-component-name> --target-version=<some-version-name>
65+
--target-version=<< pipeline.number >>
9066
----
67+
+
68+
This configuration would yield a value with the following format `12345`.
9169

92-
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.
93-
If not specified, the deployment name will be set to `default`.
94-
95-
=== 2.2. Update the deploy status
70+
=== 1.2. Update the deploy status
9671

9772
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.
9873

@@ -163,7 +138,7 @@ echo "FAILURE_REASON='Deployment was not found'" > failure_reason.env
163138

164139
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.
165140

166-
=== 2.3 Update the deploy status to canceled
141+
=== 1.3 Update the deploy status to canceled
167142

168143
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.
169144

@@ -293,10 +268,26 @@ jobs:
293268

294269
** The `environment-name` specifies the target environment. If the environment does not exist, it will be created.
295270
** The `component-name` parameter sets the name that will be displayed in the CircleCI UI.
296-
** The `target-version` parameter should match the name of the version being deployed.
271+
** The `target-version` parameter should match the name of the version being deployed. Some examples are provided <<examples-for-target-version,above>>.
297272
** (Optional) You can provide the following parameter if required:
298273
*** The `namespace` parameter can be provided to use a value other than `default`.
299274

275+
== Manage environments
276+
277+
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`.
278+
279+
You can also create an environment integration manually in the CircleCI web app.
280+
281+
=== Create an environment integration
282+
283+
. In the link:https://app.circleci.com[CircleCI web app], select your org from the org cards on your user homepage.
284+
. Select **Deploys** in the sidebar.
285+
. Select the **Environments** tab.
286+
. Select btn:[Create Environment Integration].
287+
. Enter a name for your environment, and a description if you would like.
288+
. 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.
289+
. Select btn:[Save and Continue].
290+
300291
== Manual configuration of automatically detected deploys
301292

302293
If you have some link:https://circleci.com/changelog/auto-generated-deploy-markers-are-being-sunset/[automatically detected deploy markers] you can consider manually configuring them. CircleCI no longer automatically creates deploy markers for you.

0 commit comments

Comments
 (0)