gpt4 book ai didi

powershell - Jenkins Powershell插件始终可以成功构建

转载 作者:行者123 更新时间:2023-12-03 12:15:55 40 4
gpt4 key购买 nike

我正在使用Jenkins PowerShell插件来构建项目。

但是,我发现无论我在Windows PowerShell命令中键入什么内容,Jenkins始终认为我的构建成功。

这是一个例子:

enter image description here

如您所见,asdf不是合法命令。 Jenkins应该在构建后给我FAILURE

但是控制台输出给了我:

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

这是PowerShell插件的错误吗?

最佳答案

对于插件的最新版本(Version 1.3 Sept 18 2015),必须使用$ LastExitCode才能使构建失败。

Version 1.3 (Sept 18 2015)

  • 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)

关于powershell - Jenkins Powershell插件始终可以成功构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34349333/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com