Manage workflows

4 minute read

Automate development with CloudBees platform workflows. Workflows are configurable processes, defined in a YAML file, which run jobs. Trigger your workflow by an event in your integrated repository, a manual step, or a defined schedule.

Refer to the following for detailed information on scripting a workflow YAML:

Access a workflow

To access a workflow:

  1. Select the next to Select a component, and then select a component.

  2. Select the next to Components on the left pane, and then select Workflows.

  3. (Optional) Select the next to Rows per page to display more workflows, or select the to advance to the next page.

  4. (Optional) Choose one of the following:

    • Select a workflow name to display the workflow file.

    • Select EDIT YAML to update the workflow.

    • Select CREATE WORKFLOW to create a new workflow.

You are displaying workflows for your component, listed in alphabetical order.

Create and save a workflow

Create any number of workflows using the workflow composer. Switch at any time between the visual tool and the code editor to compose or update your workflow.

To save your workflow, you must make a commit to your repository, on either the current branch or a new branch.

At this time, you cannot open a pull request to merge to the default branch.

To create and save a workflow:

  1. Select the next to Select a component, and then select a component.

  2. Select Workflows.

  3. Select CREATE WORKFLOW to display a default workflow.

    Default workflow
    Figure 1. Default workflow in the visual tool and code editor.
  4. Use either the visual tool and YAML scripting, or both together, to compose your workflow. Updates made with either the visual tool or the code editor are automatically displayed in both.

    • Select VISUAL to display only the visual tool.

    • Select SCRIPT to display only the code editor.

    • Select SPLIT to display both the visual tool and the code editor.

      When SPLIT is active, select Horizontal split to arrange the visual tool above the code editor, or select Vertical split to arrange the visual tool and code editor side by side.
  5. Select COMMIT.

  6. Enter a Commit message.

  7. Select either of the following:

    • Commit to the current branch.

    • Commit to a new branch and enter a branch name.

  8. Select FINISH.

    Commit to new branch
    Figure 2. Committing to a new branch, with FINISH highlighted.
  9. Check your repository for the commit.

    All CloudBees platform workflows for your component are saved in .cloudbees/workflows in the connected repository.
    First commit
    Figure 3. Commit in the connected GitHub repository.

Your workflow is created and listed in Workflows.

Use the workflow composer visual tool

The visual tool enables you to compose and update a workflow using the UI. Any changes in the visual tool are reflected in the YAML script.

Visual tool
Figure 4. Visual tool features.

As highlighted above, use the visual tool to perform the following activities:

  1. Switch the repository branch.

  2. Select settings to update the workflow name and input any env key/value pairs.

  3. Select JOB to add a job.

  4. Select the to update the trigger.

  5. Select the to update a job or add a step.

  6. Slide to expand or shrink the workflow display size.

Update the workflow trigger

To update the workflow push trigger:

  1. Select the next to push.

  2. Select Edit.

  3. Select Branches, and then do one or more of the following:

    • Select any of the existing branches.

    • Enter a new branch name.

    • Enter **, for any branch name.

    • Select the next to a branch to remove it.

  4. Select SAVE.

The workflow push trigger is updated accordingly.

Add a job

In the following example, selecting JOB and adding the job details creates a new job.

Add a job
Figure 5. Created job with JOB and needs input highlighted.
  • The MavenBuild job requires the Checkout job to run successfully first. To specify that a job must complete before another runs, either select ADD NEEDS or drag the job to the correct position in the visual tool.

Add job needs
Figure 6. Dragging the Checkout job to run before the MavenBuild job.

Add a step to a job

To add a step to a job:

  1. Select the next to your job, and then select Edit.

  2. Select ADD STEP.

  3. (Optional) Enter a step name.

  4. Do either of the following:

    1. Choose SELECT FROM CATALOG to add a preconfigured action, action, or container, which opens the list of actions and containers.

    2. Enter an action or container to Uses.

      Select from catalog
      Figure 7. Example of searching, with selection and APPLY SELECTED highlighted.
  5. Enter any required inputs that are not already pre-populated. Inputs marked with an are required.

    Snyk SCA scan
    Figure 8. Required inputs entered for Snyk SCA scan action.
  6. (Optional) Select from the Kind options.

    Add scan kind
    Figure 9. Scanning step with Scan kind selected.

    Select an appropriate Kind option (other than None) to associate the data from this step for analytics calculations. If the Kind option is inappropriate for the step, the data are not counted.

  7. Select SAVE.

The step is added to the workflow job in the code editor and in the visual tool.

Use the workflow composer code editor

Input your workflow script directly into the code editor. Cut, copy, and paste as you would in any code editor. You can also undo and redo input.

Use the correct YAML indentation according to the specifications. Any invalid YAML is highlighted with a wavy underline.

Update a workflow

Update your workflow with either the visual tool or the code editor in the composer.

To update a workflow:

  1. Select a component.

  2. Select the next to Components on the left pane, and then select Workflows.

  3. Select EDIT YAML next to a workflow.

  4. Make any desired changes with either the visual tool or the code editor.

  5. Select COMMIT.

  6. Enter a Commit message.

  7. Select a branch to commit from the options.

  8. Select FINISH.

  9. Check your repository for the commit. Your workflow is updated accordingly and the changes are committed to your repository, triggering a workflow run.

Delete a workflow

Delete any of your workflows. A deleted workflow is completely removed from the CloudBees platform, and deletion is irreversible.

To delete a workflow:

  1. Select a component.

  2. Select the next to Components on the left pane, and then select Workflows.

  3. Select the workflow link.

  4. Select the next to the workflow filename.

  5. Select Delete.

  6. Select CONFIRM.

Your workflow is deleted, and removed from your workflow list.