Create a Step to Upload the Pipeline.yml Buildkite

Cake Step

A cake pace is used to pause the execution of a build and wait on a squad member to unblock it using the spider web or the API.

A block pace is functionally identical to an input stride, however a block step creates implicit dependencies to the steps before and after it. Note that explicit dependencies specified by depends_on take precedence over implicit dependencies; subsequent steps volition run when the stride they depend on passes, without waiting for cake or wait steps, unless those are also explicit dependencies.

A cake step tin be divers in your pipeline settings, or in your pipeline.yml file.

Once all steps before the block have completed, the pipeline volition pause and wait for a team member to unblock it. Clicking on a block step in the Buildkite web UI opens a dialog box asking if y'all'd like to continue.

pipeline.yml
                              steps                :                -                block                :                "                :rocket:                                                Release!"                          

Screenshot of a basic block step

You tin can add form fields to cake steps by adding a fields attribute. There are two field types available: text or select. The select input blazon is displayed as radio buttons when it contains less than half-dozen items, and every bit a drop down list when information technology contains more than six items. Block steps with input fields tin can but be defined using a pipeline.yml.

Screenshot of a block step with input fields

The information you collect from these fields is then available to subsequent steps in the pipeline in the build meta-information.

In this example, the pipeline.yml defines an input step with the key release-proper name. The Bash script so accesses the value of the pace using the meta-data control.

pipeline.yml
                              -                cake                :                "                Release"                prompt                :                "                Fill                                                out                                                the                                                details                                                for                                                release"                fields                :                -                text                :                "                Release                                                Name"                primal                :                "                release-name"                          
script.sh
                              RELEASE_NAME                =                $(buildkite-agent meta-data become release-name)                          

For a complete instance pipeline, including dynamically generated input fields, see the Block Footstep Instance Pipeline on GitHub:

:pipeline: Cake Pace Instance Pipeline github.com/buildkite/block-step-example

Block step attributes

Input and block steps accept the aforementioned attributes available for use.

Optional attributes:

prompt The instructional message displayed in the dialog box when the unblock step is activated.
Example: "Release to production?"
Instance: "Fill out the details for this release"
fields A list of input fields required to be filled out earlier unblocking the step.
Available input field types: text, select
blocked_state

The land that the build is set to when the build is blocked by this cake step. The default is passed. When the blocked_state of a cake stride is set to failed, the step that triggered information technology volition be stuck in the running state until it is manually unblocked.
Default: passed
Values: passed, failed, running

If yous're using GitHub, you can also configure which GitHub status to use for blocked builds on a per-pipline footing.

branches The branch blueprint defining which branches will include this cake step in their builds.
Case: "master stable/*"
if A boolean expression that omits the step when false. Meet Using conditionals for supported expressions.
Case: build.message != "skip me"
depends_on A listing of step keys that this step depends on. This footstep will only continue afterwards the named steps have completed. See managing step dependencies for more than information.
Example: "examination-suite"
central A unique string to identify the cake stride. Case: "exam-suite"
allow_dependency_failure Whether to continue to go along by this step if any of the steps named in the depends_on aspect fail.
Default: false
pipeline.yml
                              steps                :                -                cake                :                "                :rocket:                                                Release!"                          

Text input attributes

Line endings

A text field normalizes line endings to Unix format (\due north).

Required attributes:

key The meta-data cardinal that stores the field'due south input (using the buildkite-agent meta-information control)
The key may only contain alphanumeric characters, slashes or dashes. Case: "release-name"
pipeline.yml
                              steps                :                -                block                :                "                Request                                                Release"                fields                :                -                text                :                "                Code                                                Proper noun"                cardinal                :                "                release-name"                          

Optional attributes:

hint The explanatory text that is shown after the characterization.
Example: "What's the code name for this release? :name_badge:"
required A boolean value that defines whether the field is required for form submission.
Default value: true
default The value that is pre-filled in the text field.
Case: "Flying Dolphin"
pipeline.yml
                              steps                :                -                block                :                "                Request                                                Release"                fields                :                -                text                :                "                Lawmaking                                                Proper name"                key                :                "                release-name"                hint                :                "                What's                                                the                                                code                                                name                                                for                                                this                                                release?                                                :name_badge:"                required                :                faux                default                :                "                Release                                                #"                          

Select input attributes

Required attributes:

fundamental The meta-data primal that stores the field'south input (using the buildkite-amanuensis meta-information command)
The cardinal may merely contain alphanumeric characters, slashes or dashes. Instance: "release-stream"
options The list of select field options.
For 6 or less options they'll be displayed as radio buttons, otherwise they'll be displayed in a dropdown box.
If selecting multiple options is permitted the options will exist displayed as checkboxes.

Each select option has the following required attributes:

label The text displayed for the option.
Example: "Stable"
value The value to be stored as meta-data (to exist later retrieved using the buildkite-amanuensis meta-data command)
Instance: "stable"
pipeline.yml
                              steps                :                -                block                :                "                Asking                                                Release"                fields                :                -                select                :                "                Stream"                key                :                "                release-stream"                options                :                -                label                :                "                Beta"                value                :                "                beta"                -                label                :                "                Stable"                value                :                "                stable"                          

Optional attributes:

hint The text displayed directly nether the select field's label.
Instance: "Which release stream does this vest in? :fork:"
required A boolean value that defines whether the field is required for form submission.
Default: true
multiple A boolean value that defines whether multiple options may be selected.
When multiple options are selected, they are delimited in the meta-data field by a line break (\due north)
Default: false
default The value of the option or options that will be pre-selected.
When multiple is enabled, this can be an array of values to select by default.
Case: "beta"
pipeline.yml
                              steps                :                -                block                :                "                Request                                                Release"                fields                :                -                select                :                "                Stream"                key                :                "                release-stream"                hint                :                "                Which                                                release                                                stream                                                does                                                this                                                belong                                                in?                                                :fork:"                required                :                false                default                :                "                beta"                options                :                -                label                :                "                Beta"                value                :                "                beta"                -                label                :                "                Stable"                value                :                "                stable"                          
pipeline.yml
                              steps                :                -                block                :                "                Deploy                                                To"                fields                :                -                select                :                "                Regions"                key                :                "                deploy-regions"                hint                :                "                Which                                                regions                                                should                                                we                                                deploy                                                this                                                to?                                                :earth_asia:"                multiple                :                true                default                :                -                "                na"                -                "                eur"                -                "                asia"                -                "                aunz"                options                :                -                label                :                "                North                                                America"                value                :                "                na"                -                label                :                "                Europe"                value                :                "                eur"                -                label                :                "                Asia"                value                :                "                asia"                -                label                :                "                Oceania"                value                :                "                aunz"                          

Passing block step data to other steps

Before you can do anything with the values from a block step, you need to shop the data using the Buildkite meta-information store.

Use the key attribute in your block step to store values from the text or select fields in meta-data:

pipeline.yml
                              steps                :                -                block                :                "                Request                                                Release"                fields                :                -                text                :                "                Code                                                Proper name"                key                :                "                release-name"                          

You can access the stored meta-data afterward the block pace has passed. Use the buildkite-agent meta-information get control to retrieve your data:

            buildkite-amanuensis meta-data get              "release-proper name"                      

Meta-data cannot be interpolated directly from the pipeline.yml at runtime. The meta-information store tin only be accessed from inside a command stride.

In the below example, the script uses the buildkite-amanuensis meta-data command to retrieve the meta-data and print it to the log:

                          #!/bin/fustigate              RELEASE_NAME              =              "              $(buildkite-amanuensis meta-data get              "release-name"              )              "              echo              "Release name:                            $RELEASE_NAME              "                      

Passing meta-data to trigger steps

When passing meta-data values to trigger steps you need to delay adding the trigger step to the pipeline until after the block step has completed; this tin be washed using dynamic pipelines, and works around the lack of runtime meta-information interpolation.

Yous can change a trigger footstep to dynamically upload itself to a pipeline as follows:

  1. Move your trigger footstep from your pipeline.yml file into a script. The below instance script is stored in a file named .buildkite/trigger-deploy.sh:
                          #!/bin/bash              set up              -euo              pipefail              # Ready a variable to concord the meta-data from your block step              RELEASE_NAME              =              "              $(buildkite-agent meta-information get              "release-name"              )              "              # Create a pipeline with your trigger stride              PIPELINE              =              "steps:   - trigger:                            \"              deploy-pipeline              \"                              label:                            \"              Trigger deploy              \"                              build:       meta_data:         release-name:                            $RELEASE_NAME                              "              # Upload the new pipeline and add it to the current build              echo              "              $PIPELINE              "              | buildkite-agent pipeline upload                      
  1. Supplant the old trigger stride in your pipeline.yml with a dynamic pipeline upload:

Before

The pipeline.yml file with the trigger step:

pipeline.yml
                              steps                :                -                cake                :                "                :shipit:"                fields                :                -                text                :                "                Code                                                Name"                primal                :                "                release-name"                -                trigger                :                "                deploy-pipeline"                characterization                :                "                Trigger                                                Deploy"                          

After

The pipeline.yml file dynamically uploading the trigger step:

pipeline.yml
                              steps                :                -                block                :                "                :shipit:"                fields                :                -                text                :                "                Code                                                Name"                key                :                "                release-proper noun"                -                command                :                "                .buildkite/trigger-deploy.sh"                label                :                "                Prepare                                                Deploy                                                Trigger"                          

The command pace added in the higher up example will upload the trigger stride and add together it to the end of our pipeline at runtime.

Screenshot of pipeline showing the uploaded trigger step

In the pipeline you lot're triggering, y'all will be able to use the meta-information that y'all have passed through as if information technology was set during the triggered build.

Block steps interacting with wait steps

If a block pace follows or precedes a await pace in your build, the wait step will be ignored and simply the block step will run, like in this example:

pipeline.yml
                              steps                :                -                command                :                "                .buildkite/steps/yarn"                -                wait                :                ~                -                block                :                "                unblock                                                me"                          

But permit'due south consider a different instance. Now the expect step (with continue_on_failure: true) will exist ignored, simply the block footstep will also non run, because the 'previous' control step failed.

pipeline.yml
                              steps                :                -                command                :                "                exit                                                -i"                -                expect                :                ~                continue_on_failure                :                true                -                block                :                "                unblock                                                me"                          

If you need to run a cake step later a failed footstep, gear up soft_fail on the failing step:

pipeline.yml
                              steps                :                -                command                :                "                get out                                                -1"                soft_fail                :                -                exit_status                :                "                *"                -                block                :                "                unblock                                                me"                          

kahnwavers.blogspot.com

Source: https://buildkite.com/docs/pipelines/block-step

0 Response to "Create a Step to Upload the Pipeline.yml Buildkite"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel