使用 Until 活动控制执行流

Until 活动提供的功能与 do-until 循环结构以编程语言提供的功能相同。 它在循环中将执行一组活动,直到与活动相关联的条件的计算结果为 true。 如果内部活动失败,Until 活动不会停止。 可以为 Until 活动指定超时值。

先决条件

如果要开始,必须满足以下先决条件:

使用 UI 将 Until 活动添加到管道

若要在管道中使用 Until 活动,请完成以下步骤:

创建活动

  1. 在工作区中创建新管道。

  2. 在管道的“活动”窗格中搜索“Until”,然后将其添加到管道画布上。

    Screenshot of the Fabric UI with the Activities pane and Until activity highlighted.

  3. 在画布上选择新的 Until 活动(如果尚未选择)。

    Screenshot showing the General settings tab of the Until activity.

若要配置“常规”设置选项卡,请参阅常规”设置指导。

添加管道变量

在此简单示例中,我们将测试管道变量的值。 选择管道编辑器画布的背景,然后选择“变量”选项卡,并添加名为 TestVariable 的新整数类型变量,其值为 0。

Screenshot showing the pipeline Variables tab with a variable added called TestVariable, having its value set to 0.

Until 活动设置

  1. 在管道画布上再次选择“Until”活动,然后选择“设置”选项卡。选择“表达式”字段,然后选择“添加动态内容”,并提供以下表达式:@equals(variables('TestVariable'), 1)

    Screenshot showing the expression for the Until activity.

  2. 选择“活动”选项卡,然后选择铅笔图标以编辑/将活动添加到 Until 活动,或选择管道编辑器画布上的 Until 活动上的 + 图标。 找到“设置变量”活动,然后选择它以将其添加到 Until 活动的子活动列表中。

    Screenshot showing the addition of the Set Variable activity to the Until activity's child activity list.

  3. 从管道编辑器画布上的 Until 活动的“活动窗格”内选择显示的新添加的“设置变量”活动,然后从“活动属性”窗格中选择它的“设置”选项卡。 对于“变量类型”,选择“管道变量”,然后从下拉列表中选择之前创建的 TestVariable。 对于此示例,请提供1

    Screenshot showing the settings of the Set Variable child activity of the Until activity.

进行保存,并运行或计划管道

切换到管道编辑器顶部的“开始”选项卡,然后选择“保存”按钮以保存管道。 选择“运行”来直接运行它,或者选择“计划”进行计划。 还可以在此处查看运行历史记录,或者配置其他设置。 此简单管道将执行 Until 活动的子活动恰好 1 次,将管道变量值从 0 更改为 1,之后 Until 表达式的计算结果为 true 并终止。

Screenshot showing the Home tab in the pipeline editor with the tab name, Save, Run, and Schedule buttons highlighted.