Skip to content

cloudbees-io/manual-approval

Repository files navigation

manual-approval

Use this job to request workflow execution approval.

Refer to the Manage workflows for more information.

Inputs

Table 1. Input details
Input name Data type Required? Description

approvalInputs

String, Boolean, Choice, Number

No

The input parameters for workflow approvers. Valid parameter types: string, number, boolean and choice.

These approval parameter input values can be accessed in subsequent jobs using the outputs context. For example, to return:

  • All parameter input values provided by a workflow approver in JSON format use: needs syntax of ${{needs.<approval_job_name>.outputs.approvalInputValues).<parameter_name>}}.

  • A specific approval parameter input value use: ${{ fromJSON(needs.<approval_job_name>.outputs.approvalInputValues).<parameter_name>}}.

approvers

String

No

A list of users whose participation in the workflow approval process is requested. The approvers field supports both user IDs and email addresses.

Approval rules and notifications are as follows:

  • If approvers are specified, then

    • Only listed approvers will receive email notification.

    • Only listed approvers can participate in approval process.

  • If approvers are not specified, then

    • Only the workflow initiator will receive email notification.

    • All eligible users can participate in approval process.

delegates

String

Yes

The value must be the path to the Manual approval custom job yaml file: cloudbees-io/manual-approval/custom-job.yml@v1

disallowLaunchByUser

String

No

When set to true, it prevents the user who started the workflow from participating in the approval. Default value is false.

instructions

String

Yes

Use to add instructions for approvers. This text will appear:

  • In the approval response request email notification.

  • On workflow run details screen.

timeout-minutes

Integer

No

The amount of time approvers have to respond to the approval request. The default value is 4320 minutes (three days).

Usage example

In your YAML file, add:

apiVersion: automation.cloudbees.io/v1alpha1
kind: workflow
name: Workflow example
on:
  workflow_dispatch:
jobs:
  build:
    steps:
      - uses: docker://alpine:3.23.2
        name: Say hello
        kind: test
        shell: sh
        run: |
          echo "hello world"
    needs: build-approval
  build-approval:
    with:
      approvers: ""
      disallowLaunchByUser: false
      instructions: "Please provide inputs"
      approvalInputs: |
        string-value:
          type: string
        retry-count:
          type: number
        boolean:
          type: boolean
          default: false
        Picklist:
          type: choice
          options:
            - abc
            - xyz
    timeout-minutes: 4320
    delegates: cloudbees-io/manual-approval/custom-job.yml@v1
  use-approval-parameters:
      needs:
        - build-approval
      steps:
        - uses: docker://alpine:3.23.2
          name: Echo inputs
          shell: sh
          run: |
            echo "string-value: ${{ fromJSON(needs.build-approval.outputs.approvalInputValues).string-value }}"
            echo "retry-count: ${{ fromJSON(needs.build-approval.outputs.approvalInputValues).retry-count }}"
            echo "boolean: ${{ fromJSON(needs.build-approval.outputs.approvalInputValues).boolean }}"
            echo "Picklist: ${{ fromJSON(needs.build-approval.outputs.approvalInputValues).Picklist }}"

          echo "\
            Comments:
            ${{ fromJSON(needs.build-approval.outputs.approvalInputValues).string-value }}"
Note
For more information

License

This code is made available under the MIT license.

References

About

Request manual approval from users and teams

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors