Run/Sync Conditions

This feature is only available to Pipes that have been created via the Pipekit Web UI.

Workflows (Run Conditions)

You can choose which git event(s) trigger the execution of a Pipe run, and on which cluster the resulting Pipe is executed. You can choose from the following options:

  • Git Branch

  • Git Tag

  • Git Pull/Merge Request

For each one, you can choose a specific name (eg Branch="main") or a regex (eg Branch="^feature/.*$"). Finally, for each source type and name/regex, you can define which cluster the workflow is executed on.

For example, any git branches that match the regex ^feature/.*$ could trigger the Pipe to run on the dev cluster, any git branches that match the regex ^release/.*$ could trigger the Pipe to run on the staging cluster, and any git branches that match the regex ^main$ could trigger the Pipe to run on the prod cluster.

You can choose multiple options. If you do so, the Pipe will run if any of the options are met.

CronWorkflows (Sync Conditions)

CronWorkflow Pipes operate slightly differently. As with Open Source, the Argo Workflows instance in your cluster is responsible for scheduling and triggering CronWorkflows. However, you can choose the git conditions which trigger a sync of the CronWorkflow definition from the git repository to the Argo Workflows instance in your cluster.

Pull/Merge Request Labels

If there are labels for your pull/merge requests to be used (github, gitlab), you can choose which labels will trigger the Pipe Run or the CronWorkflow sync. To use this feature, while creating a Pipe, choose the Pull Request Run Condition Source Type, and then select the label(s) you want to match against.

When a pull/merge request is submitted to the repository, Pipekit will check if the pull/merge request labels match the Run/Sync condition labels you have selected. The Pipe will then trigger a run if one of the the Run/Sync condition labels match the pull/merge request labels.

If you leave the labels field blank, the Pipe will run for all pull/merge requests matching the regex.

Environment variables and Pipe information

When triggering a Pipe via git, Pipekit injects some environment variables into the running workflow. These variables can be used to get information about the git event that triggered the Pipe and can be used by the Workflow to make decisions based on that information.

Environment Variable
Description

GIT_BRANCH_NAME

The name of the branch that the pull/merge request belongs to. Blank if triggered by a git tag event.

GIT_COMMIT

Either the sha1 of the pull/merge request. Or the name of the branch or tag that triggered the workflow.

GIT_ORG

The name of the organization that owns the repository that triggered the workflow. For github.com/pipekit/examples, it would be pipekit.

GIT_REPO_NAME

The name of the repository that triggered the workflow. For github.com/pipekit/examples, it would be examples.

GIT_REQUEST_NUMBER

The PR/MR number that triggered the Pipe run. Blank if not triggered by a pull/merge request.

GIT_SHA

The sha1 for the commit. Blank if triggered by a git tag event.

GIT_TAG

The git tag name that triggered the Pipe run. Blank if the Pipe run was not triggered by a git tag event.

GIT_TARGET_BRANCH

The name of the target branch of the pull/merge request. Blank if not triggered by a PR/MR.

Pipe information

Pipekit also injects labels into your running workflow, which you could turn into environment variables:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: get-pipe-info
spec:
  templates:
    - name: get-pipe-info
      container:
        env:
        - name: RUN_UUID
          valueFrom:
            fieldRef:
              fieldPath: metadata.labels['workflows.pipekit.io/run_uuid']
        - name: PIPE_UUID
          valueFrom:
            fieldRef:
              fieldPath: metadata.labels['workflows.pipekit.io/pipe_uuid']
        image: alpine
        command:
          - sh
          - -c
          - |
            echo: "$RUN_UUID"
            echo: "$PIPE_UUID"
            echo: "https://pipekit.io/pipes/$PIPE_UUID/runs/$RUN_UUID"

Last updated