Jenkins shell 不在 Seed DSL 生成的作业中工作
Jenkins shell not working from within Seed DSL generated Job
Groovy、闭包和 Jenkins 的新手。
我创建了一个种子作业:
def Job1 = 'FromTemplate-testJob'
job {
name Job1
steps {
shell( "echo Hello > out5.txt" )
shell( "/c echo custard > op4.txt")
}
}
如预期成功创建了包含 2 个 shell 命令的子作业:
echo Hello > out5.txt
/c echo custard > op4.txt
然而,当 运行 时,这个创建的作业显然 运行 成功,输出如下:
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\FromTemplate-testJob\workspace
[workspace] $ C:\Windows\system32\cmd.exe -xe C:\Windows\TEMP\hudson3852539874278383422.sh
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\Jenkins\jobs\FromTemplate-testJob\workspace>[workspace] $ C:\Windows\system32\cmd.exe -xe C:\Windows\TEMP\hudson1697067517687695305.sh
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\Jenkins\jobs\FromTemplate-testJob\workspace>Finished: SUCCESS
然而,这两个输出文件都不是在任何地方创建的。 shell 可执行文件定义为:
C:\Windows\system32\cmd.exe
我不明白什么?
shell
dsl command is translated to "Execute shell" build step, which usually is used on Unix-like systems. You have to use batchFile dsl 命令,因此它将被转换为 "Execute Windows batch command" 构建步骤,用于 Windows:
def Job1 = 'FromTemplate-testJob'
job {
name Job1
steps {
batchFile( "echo Hello > out5.txt" )
batchFile( "echo custard > op4.txt" )
}
}
Groovy、闭包和 Jenkins 的新手。
我创建了一个种子作业:
def Job1 = 'FromTemplate-testJob'
job {
name Job1
steps {
shell( "echo Hello > out5.txt" )
shell( "/c echo custard > op4.txt")
}
}
如预期成功创建了包含 2 个 shell 命令的子作业:
echo Hello > out5.txt
/c echo custard > op4.txt
然而,当 运行 时,这个创建的作业显然 运行 成功,输出如下:
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\jobs\FromTemplate-testJob\workspace
[workspace] $ C:\Windows\system32\cmd.exe -xe C:\Windows\TEMP\hudson3852539874278383422.sh
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\Jenkins\jobs\FromTemplate-testJob\workspace>[workspace] $ C:\Windows\system32\cmd.exe -xe C:\Windows\TEMP\hudson1697067517687695305.sh
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\Jenkins\jobs\FromTemplate-testJob\workspace>Finished: SUCCESS
然而,这两个输出文件都不是在任何地方创建的。 shell 可执行文件定义为:
C:\Windows\system32\cmd.exe
我不明白什么?
shell
dsl command is translated to "Execute shell" build step, which usually is used on Unix-like systems. You have to use batchFile dsl 命令,因此它将被转换为 "Execute Windows batch command" 构建步骤,用于 Windows:
def Job1 = 'FromTemplate-testJob'
job {
name Job1
steps {
batchFile( "echo Hello > out5.txt" )
batchFile( "echo custard > op4.txt" )
}
}