Skip to content

Review new "when" conditions and update build scripts #27

@phillipjohnston

Description

@phillipjohnston

New when conditions

We’ve added a number of new when conditions, providing you more control over whether your stages get executed.

  • equals - Compares two values - strings, variables, numbers, booleans - and returns true if they’re equal. I’m honestly not sure how we missed adding this earlier! You can do "not equals" comparisons using the not { equals … } combination too.
  • changeRequest - In its simplest form, this will return true if this Pipeline is building a change request, such as a GitHub pull request. You can also do more detailed checks against the change request, allowing you to ask "is this a change request against the master branch?" and much more.
  • buildingTag - A simple condition that just checks if the Pipeline is running against a tag in SCM, rather than a branch or a specific commit reference.
  • tag - A more detailed equivalent of buildingTag, allowing you to check against the tag name itself.
    In addition, we’ve added a new option to when: beforeAgent. This allows you to specify that the when conditions should be evaluated before entering theagent for the stage, rather than the normal behavior of evaluating when conditions after entering the agent. When beforeAgent true is specified, you will not have access to the agent’s workspace, but you can avoid unnecessary SCM checkouts and waiting for a valid `agent to be available. This can speed up your Pipeline’s execution in some cases.

https://jenkins.io/blog/2018/04/09/whats-in-declarative/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions