Pipeline stages and gates

4 minute readDeveloper productivity

Examples of stages are development (Dev), QA, user acceptance test (UAT), preproduction, and production. These stages typically map closely to the environments where applications or microservices are to be deployed.

Each stage consists of one or more entry gate rules, one or more exit gate rules, and the automation tasks to complete the stage.

  • Entry gate rules ensure all the checks and balances are met before tasks in that stage can begin

  • Exit gate rules allow you to control when a pipeline can exit a stage and what approvals are needed.

  • Tasks contain the automation logic. This is where you specify what to do.

    For example, if your stage is a test stage, it contains the tasks that must be executed to ensure that the test automation for your software delivery process is successfully completed.

  • Parameters can be created for various objects and automation tasks in the stage. This makes the pipeline reusable, allowing orchestration of the inputs and outputs for the stage and of the properties passed between stages.

  • Run if conditions, Wait until conditions, and wait dependencies can be set on pipeline objects. Refer to Pipeline Objects and Conditions for more information.

  • Wait conditions can be set for triggered pipelines, triggered releases, and specific pipelines and pipeline objects. Refer to Hierarchical Pipelines and Releases for more information.

Starting a pipeline run from tasks or stages

With the required privileges, you can start a pipeline run from a single task, group tasks, or a stage.

The task from which you start the pipeline run must have a status of not-run.

When you start a pipeline run from a task, the pipeline has a warning status and message in the stage summary.

Restarting a stage with from a task restarts the run from the starting task. Any tasks that have not completed will not run.

You cannot start a pipeline run from a gated task, a subtask that is part of a group, or start from a task with startingStage specified in the run command.

To start a pipeline run from a single task:

  1. Select the three vertical dots, then select Run from task.

    run from task
    Figure 1. Run a pipeline from a task
  2. Enter your run details.

  3. Select Run.

To start a pipeline run from a group tasks:

  1. Select the three vertical dots, then select Run from group.

  2. Enter your run details.

  3. Select Run.

You cannot start a pipeline run from a group subtask.

To start a pipeline run from a stage:

  1. Select the three vertical dots, then select Run from stage.

  2. Enter your run details.

  3. Select Run.

DSL example

// data variables def projName = 'Test Start pipeline at a task' def pipelineName = 'test pipeline' def stageNames = [s1: 'stage_1', s2: 'stage_2', s3: 'stage_3'] def taskNames = [t1 : 'task_1', t2 : 'task_2', t3 : 'task_3', subTask1: 'sub_task_1', subTask2: 'sub_task_2', group : 'group_task', gt1 : 'gate_task_1', gt2 : 'gate_task_2'] def gateConditionValue = '''/* Sample code to set the evidence on the task and pass the condition */ $[/javascript setProperty("/myTaskRuntime/evidence", "test value") true; ]''' // pipeline structure project projName, { pipeline pipelineName, { stage stageNames.s1, { gate 'PRE', { task taskNames.gt1, { gateType = 'PRE' gateCondition = gateConditionValue taskType = 'CONDITIONAL' } } gate 'POST', { task taskNames.gt2, { gateType = 'POST' gateCondition = gateConditionValue taskType = 'CONDITIONAL' } } task taskNames.t1, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.t2, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.group, { subproject = 'Default' taskType = 'GROUP' task taskNames.subTask1, { groupName = taskNames.group actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.subTask2, { groupName = taskNames.group actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } } task taskNames.t3, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } } stage stageNames.s2, { gate 'PRE', { task taskNames.gt1, { gateCondition = gateConditionValue gateType = 'PRE' taskType = 'CONDITIONAL' } } gate 'POST', { task taskNames.gt2, { gateType = 'POST' gateCondition = gateConditionValue taskType = 'CONDITIONAL' } } task taskNames.t1, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.t2, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.group, { subproject = 'Default' taskType = 'GROUP' task taskNames.subTask1, { groupName = taskNames.group actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.subTask2, { groupName = taskNames.group actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } } task taskNames.t3, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } } stage stageNames.s3, { gate 'PRE', { task taskNames.gt1, { gateCondition = gateConditionValue gateType = 'PRE' taskType = 'CONDITIONAL' } } gate 'POST', { task taskNames.gt2, { gateCondition = gateConditionValue gateType = 'POST' taskType = 'CONDITIONAL' } } task taskNames.t1, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.t2, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.group, { subproject = 'Default' taskType = 'GROUP' task taskNames.subTask1, { groupName = taskNames.group actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } task taskNames.subTask2, { groupName = taskNames.group actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } } task taskNames.t3, { actualParameter = [ 'commandToRun': 'echo success', ] subpluginKey = 'EC-Core' subprocedure = 'RunCommand' taskType = 'COMMAND' } } } } // start pipeline at a task runPipeline projectName: projName, pipelineName: pipelineName, startingTaskStage: stageNames.s2, startingTask: taskNames.t2
Figure 2. Run result
Figure 2. Run result