.run 和 .runwait

.run [-c "<condition>"] "<ProjectName>" ["<ProjectSnapshotName>"]
.runwait [-c "<condition>"] "<ProjectName>" ["<ProjectSnapshotName>"]

.run 和 .runwait 命令可用于从步骤命令启动链式项目。要指定项目的快照,请使用可选的 <ProjectSnapshotName> 参数。

这些命令的行为与它们启动了项目之后的行为不同:

根据条件启动

可以使用可选的 -c 参数设定根据条件启动。 可以在条件中使用环境变量。条件可以有几种形式:
字符串比较
可使用等于(=)或不等于(!=)运算符对字符串求值。 如果比较求值结果为 true,那么启动链。
数字比较
可以使用 <、>、<>、>< 或 = 运算符比较两个数字值。
命令成功
可以将用反引号括起来的命令用作 -c 参数的值。 系统运行此命令;如果成功,那么启动链。

示例

.run "BuildWindowsDriver"

系统启动 BuildWindowsDriver 项目。正在启动的项目将立即继续执行下一步。

.runwait "BuildWindowsDriver"

系统启动 BuildWindowsDriver 项目。系统在 .runwait 步骤暂停正在启动的项目。当 BuildWindowsDriver 项目完成并通过时,.runwait 步骤的状态将设置为 pass。

.run -c "$HOMEDRIVE=C:" "Simple Echo"

当且仅当 HOMEDRIVE 变量的值为 C 时,系统才运行 Simple Echo 项目。

此命令会生成如下日志输出(在步骤日志的 EXEC 部分):
  • 当 HOMEDRIVE 为 C: 时
    .run Condition: 'C:' = 'C:' satisfied.
    
    Queueing Project "Simple Echo" on server [WinBox].
    Queued Build 'BUILD_202' of project 'Simple Echo'.
  • 当 HOMEDRIVE 不为 C: 时
    .run -c "$HOMEDRIVE=C:" "Simple Echo"     
    
    .run Condition: 'D:' = 'C:' unsatisfied, no project queued.

如果字符串包含数字,系统将比较这些字符串的数字部分。例如,将以如下方式进行处理。

.runwait -c "a12b<c42d" "Simple Echo"

.run Condition: '12' < '42' satisfied. 
Queueing Project "Simple Echo" on server [WinBox]. 
Waiting for .run build (4411) to complete. 
.run build is now running. 
.run build has finished. 
Build 'BUILD_203' of project 'Simple Echo' completed. 

.runwait -c "f43g<>h43i" "Simple Echo"

.run Condition: '43' <> '43' unsatisfied, no project queued. 

下列示例显示如何将命令用作条件:请注意:必须将命令用引号和反引号括起来。

.run -c "`exit 1`" "Simple Echo"

Env .run encountered an error during variable expansion,
parameter [`exit1`] expanded to [].
Expansion returned non-zero exit, project will not be queued. 

.run -c "`exit 0`" "Simple Echo"

Expansion returned zero exit, project will be queued.
Queueing Project "Simple Echo" on server [WinBox]. 
Queued Build 'BUILD_204' of project 'Simple Echo'.

使用 .runwait 但构建失败时,日志将类似如下内容。

.runwait "Fail Build"

Queueing Project "Fail Build" on server [WinBox]. 
Waiting for .run build (4413) to complete. 
.run build is now running. 
.run build has finished. 
Build 'BUILD_3' of project 'Fail Build' Failed, setting step status to fail.

反馈