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

Kb how to cleanup#950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
NimRegev merged 8 commits intomasterfromkb-how-to-cleanup
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions_docs/kb/articles/check-env-vars-in-conditionals.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,13 +11,9 @@ categories: [Pipelines]
support-reviewed: 2023-04-18 LG
---

## Overview
This article outlines how to execute a specific step conditionally based on the presence or absence of a variable in Codefresh pipelines, enabling branching logic within a single pipeline.

You are trying to run a specific step only if a variable is set. You are trying to have branching logic in one pipeline.


This condition determines how values are substituted for variables, when and if referenced variables do not exist in the pipeline definitions. In such cases, Codefresh retains the variable name string as-is, without substituting it with a value.

The condition determines how variable values are substituted within the pipeline's build when these variables are not defined in the pipeline configuration. In such instances, Codefresh maintains the variable name string unchanged, without replacing it with a value.

The following condition:

Expand All@@ -30,9 +26,11 @@ The following condition:

evaluates to `true` if `CF_RELEASE_TAG` does not exist, and `false` if it does exist.

##Details
##How to

1. Using the following syntax, you can check whether a variable exists for the current build:
##### Check if variable exists for the current build

Use the following syntax:

{% raw %}

Expand All@@ -45,7 +43,9 @@ evaluates to `true` if `CF_RELEASE_TAG` does not exist, and `false` if it does e

{% endraw %}

2. The following syntax can be used to check for a specific value:
##### Check if variable has a specific value

Use the following syntax:

{% raw %}

Expand All@@ -58,9 +58,9 @@ evaluates to `true` if `CF_RELEASE_TAG` does not exist, and `false` if it does e

{% endraw %}

3. If desired, you can combinemultiple checks.
Combinemultiple checks as required.



## RelatedItems
[Conditional execution of steps]({{site.baseurl}}/docs/pipelines/conditional-execution-of-steps/)
## Relatedarticles
[Conditional execution of steps]({{site.baseurl}}/docs/pipelines/conditional-execution-of-steps/)
26 changes: 14 additions & 12 deletions_docs/kb/articles/check-out-pr-merge-commit-not-target.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
---
title: "How To: Check out onlythe PR merge commit, and not the HEAD ofthe target branch"
title: "How To: Check out onlypull request merge commit for target branch instead ofHEAD"
description:
group: kb
sub-group: articles
Expand All@@ -11,22 +11,24 @@ categories: [Pipelines]
support-reviewed: 2023-05-04 LG
---

## Overview
This article describes how to check out only the merge commit of a PR (Pull Request) instead of the HEAD of the target branch.

Sometimes, when you re-run a pipeline based on a PR you might find your tests that passed the first time failing the second time. This can happen because the default behavior of your pipeline is to run based on a merge of the PR and the HEAD of the target branch - so it includes the latest changes to HEAD that may not have present when the PR itself was first made.
When re-running a pipeline based on a PR, tests that passed the previous fails during the rerun.
This can happen because the default behavior of the pipeline is to run based on a merge of the PR and the HEAD of the target branch. This behavior includes the latest changes to HEAD which may not have been present when the PR itself was created.

## Details

If you want a pipelineto only runagainst the target branch asit wasat the time of thepull request, you can clone your repository using the exact SHA of the merge request.
To only run the pipeline against the target branch as at the time of thePR, clone your repository using the exact SHA of the merge request.

WhenCodefreshis triggered by aPull Request, your pipeline will haveaccess tosomeadditional variables[1]. This includesCF_PULL_REQUEST_MERGED_COMMIT_SHA, which is the commit SHA on the base branch after thepull request was merged.
Whenthe pipelineis triggered by aPR, it hasaccess to additional variablesincluding `CF_PULL_REQUEST_MERGED_COMMIT_SHA`, which is the commit SHA on the base branch after thePR was merged.

You can set up your pipeline to test and see if this variable exists [2], and depending on it's existence do two different clone steps. One clone as your existing clone if the variable is not there, or a second clone step if it is that uses CF_PULL_REQUEST_MERGED_COMMIT_SHA in the `revision` field of your clone step [3] to check out your codebase as it was at the exact moment of the PR with the PR merged into it.
Configure [conditional execution for the pipeline]({{site.baseurl}}/docs/pipelines/conditional-execution-of-steps/) to check if the `CF_PULL_REQUEST_MERGED_COMMIT_SHA` variable exists.
Depending on result, execute one of two `git-clone` steps:
* If the variable exists, specify it in the `revision` field of your `git-clone` step. This ensures that your codebase is checked out to the state it was at the precise moment the PR was merged.
* If the variable does not exist, continue with your regular clone process.

## Related Items

[1] <https://codefresh.io/docs/docs/pipelines/variables/#github-pull-request-variables>

[2] <https://codefresh.io/docs/docs/kb/articles/check-env-vars-in-conditionals/>

[3] <https://codefresh.io/docs/docs/pipelines/steps/git-clone/#fields>
## Related articles
[GitHub Pull Request variables]({{site.baseurl}}/docs/pipelines/variables/#github-pull-request-variables)
[Check environment variable value or existence in conditionals]({{site.baseurl}}/kb/articles/check-env-vars-in-conditionals)
[Fields for `git-clone` step]({{site.baseurl}}/docs/pipelines/steps/git-clone/#fields)
7 changes: 5 additions & 2 deletions_docs/kb/articles/check-potentially-unstable-service.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,7 +19,9 @@ This article describes how to check for a service that may be inaccessible for a

## How to

* In the pipline step, add the `retry` attribute, as in the following example:
* In the pipeline step, add the `retry` attribute, as in the following example:



```yaml
steps:
Expand All@@ -33,7 +35,8 @@ steps:
exponentialFactor: 2
```

>**NOTE**

>**NOTE**
Every retry attempt uses up one of your concurrent builds. For this reason, we suggest limiting the amount of retries.

## Related articles
Expand Down
28 changes: 17 additions & 11 deletions_docs/kb/articles/clone-backup-pipelines-projects.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,23 +11,30 @@ categories: [Pipelines, CLI]
support-reviewed: 2023-04-18 LG
---

## Overview

You would liketo back up yourPipelines orProjects locally.
This article describes howto back up yourpipelines orprojects locally.

##Details
##How to

You will need to have the [Codefresh CLI installed](https://codefresh-io.github.io/cli/installation/). When installed, run the following command:
##### Prerequisite
[Install the Codefresh CLI](https://codefresh-io.github.io/cli/installation/).

{% raw %}
##### Commands

**Back up the pipeline**

{% raw %}
```shell
codefresh get pip "pipeline_name" -o yaml > pipeline_backup_file
codefresh get pip "<pipeline_name>" -o yaml ><pipeline_backup_file>
```

{% endraw %}

If you would like to export protected variables, run the following:
where:
* `"<pipeline_name>"` is the name of the pipeline to back up.
* `<pipeline_backup_file>` is the name of the file to which to save the backed up pipeline.


**Export protected variables**

{% raw %}

Expand All@@ -37,7 +44,8 @@ codefresh get pip "pipeline_name" --decrypt-variables -o yaml > pipeline_backup

{% endraw %}

To recreate a pipeline from a backup file, run the following command:

**Recreate a pipeline from a backup file**

{% raw %}

Expand All@@ -47,6 +55,4 @@ codefresh replace -f pipeline_backup_file

{% endraw %}

## Related Items

[Codefresh CLI](https://codefresh-io.github.io/cli/installation/)
29 changes: 15 additions & 14 deletions_docs/kb/articles/clone-target-instead-of-branch-on-pr.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
---
title: "How To: Clone target instead of source branchon pull request"
title: "How To: Clone target instead of source branchfor pull request"
description:
group: kb
sub-group: articles
Expand All@@ -11,19 +11,24 @@ categories: [Pipelines]
support-reviewed: 2023-04-18 LG
---

## Overview
This article describes how to clone the target instead of the source branch in a PR (pull request)-triggered build.

In most cases,buildswilluse thevariable`CF_BRANCH` to referencethebranchassociated with agit triggered build.
Typically, pipelinebuilds use the `CF_BRANCH`variableto referencethe branchassociated with abuild triggeredby a Git event. However, in the case of abuild triggered by a PR, `CF_BRANCH` specifically references the source branch. To clone the _target branch_ instead of the _source branch_ during a merge, use the `CF_PULL_REQUEST_TARGET` variable, which specifically points to the target branch.

In a pull request triggered build, `CF_BRANCH` specifically refers to the
source branch, and another variable `CF_PULL_REQUEST_TARGET` refers to the
target branch. You may need to use the target branch instead in your merge
build.

## Details

* Create a separate pipeline that uses {% raw %}`${{CF_PULL_REQUEST_TARGET}}`{% endraw %} instead of the standard {% raw %}`${{CF_BRANCH}}`{% endraw %} or
* Add the following step before your clone step to check if `CF_PULL_REQUEST_TARGET` exists, and if it does assign its value to `CF_BRANCH`:
## How to

>**NOTE**
`CF_BRANCH` is available only for PR-triggered builds. Updating its value to match `CF_PULL_REQUEST_TARGET` clones the target branch instead.
If `CF_PULL_REQUEST_TARGET` is not present, the build defaults to cloning the source branch.

<!--- >>💡 The ability to override predefined variables such as `CF_BRANCH` was added recently and may be disabled for your account. If the approach described in this article does not work in your account, please [contact support](https://support.codefresh.io/hc/en-us/requests/new). -->

* Create a separate pipeline that uses {% raw %}`${{CF_PULL_REQUEST_TARGET}}`{% endraw %} instead of the standard {% raw %}`${{CF_BRANCH}}`{% endraw %}
OR
* Add the following step before your `git-clone` step to check if `CF_PULL_REQUEST_TARGET` exists.
If it does, to assign its value to `CF_BRANCH`:

{% raw %}

Expand All@@ -44,8 +49,4 @@ build.

{% endraw %}

>_Note:_
>
>`CF_BRANCH` is the source branch in a PR-initiated build. By updating its value to the value of `CF_PULL_REQUEST_TARGET` the target will be pulled instead. This variable only exists for PR triggered builds, and if not present the build will clone the source branch instead.

>💡 The ability to override predefined variables such as `CF_BRANCH` was added recently and may be disabled for your account. If the approach described in this article does not work in your account, please [contact support](https://support.codefresh.io/hc/en-us/requests/new).
39 changes: 20 additions & 19 deletions_docs/kb/articles/debug-mode-cli.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,41 +11,42 @@ categories: [Pipelines, CLI]
support-reviewed: 2023-04-18 LG
---

## Overview
This article describes how to enable debug mode when using the Codefresh CLI for pipeline management.
Enabling the `debug` mode provides detailed output helping you to understand the reasons for potential issues.

When you're running commands using Codefresh CLI you may face some issues related to:
Debig mode is useful when facing issues related to:
* Authentication
* Network access, such as connectivity to the Codefresh platform
* Delays or errors during command execution, as when running a pipeline locally

* Authentication problems
* Network-related issues (e.g.: trying to reach Codefresh platform)
* Delays or errors executing a command (e.g.: running a pipeline locally)
>**NOTE**
Make sure you have the [latest version of the CLI](https://codefresh-io.github.io/cli/installation/){:target="\_blank"}.

By enabling the `debug` mode when using the Codefresh CLI, you will get more verbose output, which will help you to understand where and when a potential issue is happening.
## How to

## Details

1. Enable the `debug` mode for the Codefresh CLI: to do so, you need to initialize the `DEBUG` environment variable as follows:
1. Initialize the `DEBUG` environment variable:

```shell
DEBUG=codefresh*
```

2. Run the Codefresh CLI command you would like to debug. For example:
1. Run the Codefresh CLI command you want to debug.
For example:

```shell
codefresh run my-project/my-pipeline --local
```

(or any other Codefresh CLI command)

3. You will get an output similar to this:
1. Analyze the output to identify issues.
Below is an example of CLI command output in debug mode.

![Codefresh CLI debug output]({{site.baseurl}}/images/troubleshooting/cli-debug-mode.png)

>**_Note:_**
>
>If after reviewing the output provided by the debug mode you're still unable to fix the issue, please include that output in a ticket. That way the Support Team will be able to help you.
{{site.data.callout.callout_tip}}
**TIP**
If after analyzing the debug output you're unable to resolve the issue, please submit a ticket to Codefresh Support, including the output details.
{{site.data.callout.end}}

## Related Items
## Related articles
[Codefresh CLI documentation](https://codefresh-io.github.io/cli/)

* [Codefresh CLI documentation](https://codefresh-io.github.io/cli/)
* [Codefresh CLI Installation and upgrade process](https://codefresh-io.github.io/cli/installation/) (it's important to keep your Codefresh CLI up to date)
22 changes: 12 additions & 10 deletions_docs/kb/articles/disable-status-updates-to-github.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,21 +11,23 @@ categories: [Pipelines, CLI, Settings]
support-reviewed: 2023-04-18 LG
---

## Overview

You need to option to stop status update to github from a pipeline

## Details
This article describes how to stop status update from a pipeline to GitHub.

To disable status updates to Github, please follow these steps (it's currently supported only via CLI):
>**NOTE**
Disabling status updates to GitHub is currently supported only via CLI for Codefresh pipelines.

1. Install the Codefresh CLI: <https://codefresh-io.github.io/cli/installation/>
## Before you begin

2. Authenticate the CLI to your Codefresh account: <https://codefresh-io.github.io/cli/authentication/>
* Install the CLI](https://codefresh-io.github.io/cli/installation/){:target="\_blank"}
* [Authenticate the CLI to your Codefresh account](https://codefresh-io.github.io/cli/authentication/){:target="\_blank"}

3. Run `codefresh get pipeline <project_name/pipeline_name> -o yaml > pipeline_name_spec.yaml` to export the full pipeline spec as a YAML file
## How to

4. Add the options section under `spec`, set `enableNotifications: false` and save the changes. The updated YAML should look like this:
1. Export the full pipeline spec as a YAML file:
`codefresh get pipeline <project_name/pipeline_name> -o yaml > pipeline_name_spec.yaml` to
1. Below `spec`, add `options` and then add `enableNotifications: false`, as in the example below.

```yaml
version: '1.0'
Expand All@@ -35,5 +37,5 @@ To disable status updates to Github, please follow these steps (it's currently s
options:
enableNotifications: false
```

5. Run the `codefresh replace pipeline -f pipeline_name_spec.yaml` to update your pipeline from the YAML file
1. Save the changes and close the YAML.
5. Run the `codefresh replace pipeline -f pipeline_name_spec.yaml` to update your pipelinewith the specificationsfrom the YAML file.
26 changes: 16 additions & 10 deletions_docs/kb/articles/ensure-cleanup-when-pipelines-stops.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
---
title: "How To:Ensure Clean Up CommandsAlwaysRun If a Pipeline Is Manually Stopped"
title: "How To: Alwaysrun clean-up commands after pipeline execution"
description:
group: kb
sub-group: articles
Expand All@@ -11,13 +11,21 @@ categories: [Pipelines]
support-reviewed: 2023-05-04 LG
---

## Overview

Sometimes you might want to run code at the end of every pipeline (eg to clean up resources) regardless of success, failure, or the pipeline is manually stopped.

## Details
This article describes how to insert a parallel step within a sequential pipeline to run specific commands at the end of pipeline execution. A common use case for this approach is automating resource cleanup tasks.

When working with a sequential (default) pipeline, you will find that manually stopping a pipeline halts the entire pipeline - including any pipeline hooks set to run on_success or on_failure [1]. However, if you switch the entire pipeline work in parallel [2], you can use the below step as a template to ensure that your clean up code will always run:
The parallel step always runs at the end of the pipeline, regardless of its build status, or if the pipeline was manually terminated.



## How to

In a sequential pipeline, which is the default execution mode for pipelines, manually terminating the pipeline, also terminates the execution of subsequent steps, including any pipeline hooks set to run on success or failure.

You can circumvent this behavior by inserting a parallel step within the pipeline.

* Add the step below as a template to ensure code clean-up will always run:

```yaml
cleaner_always_executed:
Expand All@@ -32,8 +40,6 @@ cleaner_always_executed:
buildSuccess: workflow.result == 'success'
```

## Related Items

[1] <https://codefresh.io/docs/docs/pipelines/hooks/>

[2] <https://codefresh.io/docs/docs/pipelines/advanced-workflows/#parallel-pipeline-mode>
## Related articles
[Hooks in pipelines]({{site.baseurl}}/docs/pipelines/hooks/)
[Parallel pipeline execution]({{site.baseurl}}/docs/pipelines/advanced-workflows/#parallel-pipeline-execution)
Loading

[8]ページ先頭

©2009-2025 Movatter.jp