new to Groovy, Closures &詹金斯。
我已经创建了一个种子作业:
def Job1 = 'FromTemplate-testJob'
job {
name Job1
steps {
shell( "echo Hello > out5.txt" )
shell( "/c echo custard > op4.txt")
}
}
,如预期的那样成功地创建了包含两个shell命令的子作业:
echo Hello > out5.txt
/c echo custard > op4.txt
然而,当运行时,这个创建的作业显然运行成功,输出如下:
Started by user anonymous
Building in workspace C:Program Files (x86)JenkinsjobsFromTemplate-testJobworkspace
[workspace] $ C:Windowssystem32cmd.exe -xe C:WindowsTEMPhudson3852539874278383422.sh
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:Program Files (x86)JenkinsjobsFromTemplate-testJobworkspace>[workspace] $ C:Windowssystem32cmd.exe -xe C:WindowsTEMPhudson1697067517687695305.sh
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:Program Files (x86)JenkinsjobsFromTemplate-testJobworkspace>Finished: SUCCESS
但是,这两个输出文件都没有在任何地方创建。shell可执行文件定义为:
C:Windowssystem32cmd.exe
我有什么不明白的吗?
shell
dsl命令被翻译为"Execute shell"构建步骤,通常用于类unix系统。您必须使用batchFile dsl命令代替,因此它将被翻译为"执行Windows批处理命令"构建步骤,这用于Windows:
def Job1 = 'FromTemplate-testJob'
job {
name Job1
steps {
batchFile( "echo Hello > out5.txt" )
batchFile( "echo custard > op4.txt" )
}
}