Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51aa1f3

Browse files
authored
Update variables.md (#891)
* Update variables.md* Update variables.md* Add cf_predecssor* Add new annotation and variableAdded cf_predecessor annotation and CF_OUTPUT variable* Add CF_OUTPUT_URL to variablesAdded CF_OUTPUT_URL* Update variables.md* Update annotations.md
1 parent52ed815 commit51aa1f3

File tree

2 files changed

+78
-15
lines changed

2 files changed

+78
-15
lines changed

‎_docs/pipelines/annotations.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ steps:
134134

135135

136136

137-
##Add annotations to the current build/image
137+
####Example 3: Add annotations to the current build/image
138138

139-
Define annotations at the root level of the`build` step toadd an annotation to the current build or image without defining the entity type and ID.
139+
Toadd an annotation to the current build or image without defining the entity type and ID, add it at the root level of the`build` step.
140140

141141
This method provides a way to add annotations without the entity type and ID, compared to post-step operations where you explicitly define the target type and ID.
142142

@@ -176,6 +176,12 @@ codefresh get annotation build 5ce26f5ff2ed0edd561fa2fc
176176

177177
You can also define`entity_type` as`image` and don't enter any`entity_id`. In this case the image created from the build step will be annotated.
178178

179+
##`cf_predecessor` for BUILD_ID of parent pipeline
180+
Codefresh has native support to navigate from parent to child builds.
181+
To navigate from the child build to its parent, we have the`cf_predecessor` annotation.
182+
183+
The`cf_predecessor` annotation is automatically added to builds executed by calls to a[`codefresh-run` plugin](https://codefresh.io/steps/step/codefresh-run){:target="\_blank"}.
184+
By querying the value of this annotation in the child build, you can get the ID of the parent build.
179185

180186

181187
##Managing annotations

‎_docs/pipelines/variables.md‎

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Gerrit has `change-Id` and `Changes` that you can map to `CF_PULL_REQUEST` varia
121121
| {% raw %}`${{CF_PIPELINE_NAME}}`{% endraw %}| The full path of the pipeline, i.e. "project/pipeline"|
122122
| {% raw %}`${{CF_STEP_NAME}}`{% endraw %}| the name of the step, i.e. "MyUnitTests"|
123123
| {% raw %}`${{CF_URL}}`{% endraw %}| The URL of Codefresh system|
124+
| {% raw %}`${{CF_OUTPUT_URL}}`{% endraw %}| Display link to an external URL on step execution. For example, display the link to a parent-build from the child-build.<br>See[Export external link with CF_OUTPUT_URL](#export-external-link-with-cf_output_url) in this article.|
124125
| {% raw %}`${{CI}}`{% endraw %}| The value is always`true`|
125126
| {% raw %}`${{CF_KUBECONFIG_PATH}}`{% endraw %}| Path to injected kubeconfig if at least one Kubernetes cluster is[configured]({{site.baseurl}}/docs/integrations/kubernetes/#connect-a-kubernetes-cluster). You can easily run[custom kubectl commands]({{site.baseurl}}/docs/deployments/kubernetes/custom-kubectl-commands/) since it is automatically setup by Codefresh in all pipelines.|
126127
| Any variable specified in the pipeline settings| For example, if you configure the pipeline settings with a variable named PORT, you can put the variable in your YAML build descriptor as {% raw %}`${{PORT}}`{% endraw %}.|
@@ -169,13 +170,13 @@ Variables that are created by steps can have members. The members depend on the
169170
{: .table .table-bordered .table-hover}
170171
| Step Type| Members|
171172
| -----------------------| --------------------------------------|
172-
| All step types| {::nomarkdown}<ul><li>name</li><li>type</li><li>description</li><li>workingDirectory</li><li>result</li></ul>{:/}
173-
|[Freestyle]({{site.baseurl}}/docs/pipelines/steps/freestyle/)| -|
174-
|[Composition]({{site.baseurl}}/docs/pipelines/steps/composition/)| -|
175-
|[Build]({{site.baseurl}}/docs/pipelines/steps/build/)| {::nomarkdown}<ul><li>imageName</li><li>imageTagName</li><li>imageId</li></ul>{:/}|
176-
|[Git-clone]({{site.baseurl}}/docs/pipelines/steps/git-clone/)| {::nomarkdown}<ul><li>revision</li><li>repo</li></ul>{:/}|
177-
|[Push]({{site.baseurl}}/docs/pipelines/steps/push/)| {::nomarkdown}<ul><li>registry</li><li>imageId</li><li>imageRepoDigest</li></ul>{:/}|
178-
|[Approval]({{site.baseurl}}/docs/pipelines/steps/approval/)| {::nomarkdown}<ul><li>authEntity.name</li><li>authEntity.type</li></ul>{:/}|
173+
| All step types| {::nomarkdown}<ul><li>name</li><li>type</li><li>description</li><li>workingDirectory</li><li>result</li></ul>{:/}|
174+
|[Freestyle]({{site.baseurl}}/docs/pipelines/steps/freestyle/)| -|
175+
|[Composition]({{site.baseurl}}/docs/pipelines/steps/composition/)| -|
176+
|[Build]({{site.baseurl}}/docs/pipelines/steps/build/)| {::nomarkdown}<ul><li>imageName</li><li>imageTagName</li><li>imageId</li></ul>{:/}|
177+
|[Git-clone]({{site.baseurl}}/docs/pipelines/steps/git-clone/)| {::nomarkdown}<ul><li>revision</li><li>repo</li></ul>{:/}|
178+
|[Push]({{site.baseurl}}/docs/pipelines/steps/push/)| {::nomarkdown}<ul><li>registry</li><li>imageId</li><li>imageRepoDigest</li></ul>{:/}|
179+
|[Approval]({{site.baseurl}}/docs/pipelines/steps/approval/)| {::nomarkdown}<ul><li>authEntity.name</li><li>authEntity.type</li></ul>{:/}|
179180

180181

181182

@@ -208,8 +209,6 @@ When a pull request is closed in GitHub, the following variables are also availa
208209
| {% raw %}`${{CF_PULL_REQUEST_HEAD_COMMIT_SHA}}`{% endraw %}| the commit SHA on the head branch (the branch that we want to push)|
209210

210211
##Gerrit changeId & change message variables
211-
212-
213212
Gerrit has no explicit concept of pull requests, as in other version control systems, to map trigger event payloads to builds. Instead, Gerrit uses`Changes` which serves a similar purpose and functionality as pull requests. You can achieve the same functionality in Codefresh with our`CF_PULL_REQUEST` group of environment variables.
214213

215214

@@ -224,11 +223,11 @@ Gerrit has no explicit concept of pull requests, as in other version control sys
224223

225224
##User-defined variables
226225

227-
User variables can be defined at6 levels:
226+
User variables can be defined atsix levels:
228227

229-
1. Manually within a step using the[export](http://linuxcommand.org/lc3_man_pages/exporth.html){:target="\_blank"} command or in any**subsequent** stepwith the[cf_export](#using-cf_export-command) command
230-
1.[Freestyle step definition]({{site.baseurl}}/docs/pipelines/steps/freestyle/#examples) (using the`environment` field)
231-
1. Specific buildExecution (after clicking the "Build" button open the "Build Variables" section, or use the[CLI]({{site.baseurl}}/docs/integrations/codefresh-api/#example---triggering-pipelines))
228+
1. Manually within a step using the[export](http://linuxcommand.org/lc3_man_pages/exporth.html){:target="\_blank"} command, or in any**subsequent** stepusing the[cf_export](#using-cf_export-command) command
229+
1.[Freestyle step definition]({{site.baseurl}}/docs/pipelines/steps/freestyle/#examples),using the`environment` field
230+
1. Specific buildexecution (after clicking the "Build" button open the "Build Variables" section, or use the[CLI]({{site.baseurl}}/docs/integrations/codefresh-api/#example---triggering-pipelines))
232231
1. Pipeline Definition (under "Environment variables" section in the[pipeline view]({{site.baseurl}}/docs/pipelines/pipelines/#creating-new-pipelines))
233232
1.[Shared Configuration]({{site.baseurl}}/docs/pipelines/configuration/shared-configuration/) (defined under your account settings, and used using the "Import from shared configuration" button under the "Environment Variables" section in the pipeline view)
234233
1. Variables defined on the Project level (Under the variables tab on any project view)
@@ -237,6 +236,12 @@ The options are listed in order of priority (from the most important to the leas
237236

238237
For example if a pipeline variable is defined both in project level and as an execution parameter of a specific build, then the final result will be the value defined as a build parameter and the project level variable will not take effect.
239238

239+
240+
241+
242+
243+
244+
240245
##Exporting environment variables from a freestyle step
241246

242247
Steps defined within steps are scoped to the step they were created in (even if you used the`export` command). To use variables across steps, we provide a shared file through which you can import and export variables.
@@ -245,12 +250,19 @@ There are two ways to add variables to the shared file:
245250
* Using the`cf_export` command
246251
* Writing directly to the file
247252

253+
254+
255+
256+
257+
248258
###Exporting variables with`cf_export`
249259
Within every freestyle step, the`cf_export` command allows you to export variables across steps by writing to the shared variables file.
250260

261+
251262
>**NOTE**
252263
The variables exported through`cf_export` overrides those at the pipeline-level.
253264

265+
254266
You can either:
255267
- Explicitly state a VAR=VAL pair
256268
- State the name of an existing*exported* environment variable (like EXISTING_VAR).
@@ -365,6 +377,51 @@ steps:
365377

366378
Use this technique if you have complex expressions that have issues with the`cf_export` command.
367379

380+
##Export external link with`CF_OUTPUT_URL`
381+
382+
Codefresh has native support to trigger child builds from parent builds, and to navigate from the parent to the child build through the`codefresh-run` plugin ([link](https://codefresh.io/steps/step/codefresh-run)).
383+
Using the`CF_OUTPUT_URL` variable, you can also navigate from the child build back to the parent build.
384+
385+
Simply add a step to the child build with an in-step link to the parent build. The URL link to the parent build is displayed as part of the step details in the Builds page.
386+
387+
{{site.data.callout.callout_tip}}
388+
**TIP**
389+
Every build executed by a call to a`codefresh-run` plugin is enriched with a special annotation that precisely identifies its parent, the[`cf_predecessor` annotation]({{site.baseurl}}/docs/pipelines/annotations/#cf_predecessor-for--build_id--of-parent-pipeline).
390+
You can get the ID of the parent build by querying the value of this annotation in the child build.
391+
{{site.data.callout.end}}
392+
393+
394+
#####Add`CF_OUTPUT_URL` with`cf_export`
395+
Create a link to the parent-build using`cf_export` and`CF_OUTPUT_URL`.
396+
`
397+
398+
#####Example step in child build to output link to parent
399+
400+
Add the following step at the beginning of the pipeline.
401+
402+
>**NOTE**
403+
The name of the variable exported by `cf_export` must have the format `<name|key_of_step>_CF_OUTPUT_URL`. It's value is the URL of the parent build to link to.
404+
405+
{% raw %}
406+
407+
```yaml
408+
steps:
409+
...
410+
linkToParentBuild:
411+
image:codefresh/cli
412+
commands:
413+
-export parentBuildId=$(codefresh get annotation build ${{CF_BUILD_ID}} cf_predecessor -o json | jq -r '.value')
414+
-cf_export linkToParentBuild_CF_OUTPUT_URL="${{CF_URL}}/build/${parentBuildId}"
415+
...
416+
```
417+
{% endraw %}
418+
419+
420+
421+
In the Builds page, the step details of the child build displays the**Output URL** which is the link to the parent build, as in the image below.
422+
423+
![Link to Parent-build]({{site.baseurl}}/images/troubleshooting/how-to-navigate-to-parent-build-from-child-build.png)
424+
368425
##Masking variables in logs
369426

370427
Codefresh has the built-in capability to automatically mask variables in logs if they are encrypted. The values of encrypted variables will be replaced with asterisks in build logs.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp