Jenkins Powershell插件始终可以成功构建 [英] Jenkins powershell plugin always builds successfully
问题描述
我正在使用Jenkins PowerShell插件来构建项目.
I'm using Jenkins PowerShell plugin to build a project.
但是,我发现无论我在Windows PowerShell
命令中键入什么内容,Jenkins总是认为我的构建成功.
However, I found that Jenkins always considers my build successful no matter what I type inside Windows PowerShell
command.
这是一个例子:
如您所见,asdf
不是合法命令. Jenkins应该在构建后给我FAILURE
.
As you can see, asdf
isn't a legal command. Jenkins should give me FAILURE
after the build.
但是控制台输出给了我
Started by user admin
Building in workspace C:\Users\Administrator\.jenkins\jobs\Test\workspace
[workspace] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\ADMINI~1\AppData\Local\Temp\hudson2092642221832331776.ps1'"
The term 'asdf' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\ADMINI~1\AppData\Local\Temp\hudson2092642221832331776.ps1:1 char:5
+ asdf <<<<
+ CategoryInfo : ObjectNotFound: (asdf:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Finished: SUCCESS
我认为PowerShell的执行结果应取决于$lastexitcode
.
I think the execution result of PowerShell should depend on $lastexitcode
.
这是PowerShell插件的错误吗?
Is this a bug of PowerShell plugin?
推荐答案
每个最新版本的插件(版本1.3(2015年9月18日),则必须使用$ LastExitCode才能使构建失败.
Per the latest version of the plugin (Version 1.3 Sept 18 2015), you must use $LastExitCode to fail a build.
1.3版(2015年9月18日)
Version 1.3 (Sept 18 2015)
- PowerShell现在以非交互模式运行,以防止交互提示挂起构建
- PowerShell现在可以在ExcecutionPolicy设置为绕过"的情况下运行,以避免执行策略问题
- 脚本现在以$ LastExitCode退出,导致非零退出代码将构建标记为失败
- 添加了帮助和可用的环境变量列表(包括英语和法语翻译)
- PowerShell now runs in Non-Interactive mode to prevent interactive prompts from hanging the build
- PowerShell now runs with ExcecutionPolicy set to "Bypass" to avoid execution policy issues
- Scripts now exit with $LastExitCode, causing non-zero exit codes to mark a build as failed
- Added help and list of available environment variables (including English and French translations)
这篇关于Jenkins Powershell插件始终可以成功构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!