是否可以通过脚本(bat或sh)与Jenkins Pipeline进行交互?例如,启动新的阶段?
echo This is a batch file in no stage
pipeline.stage(build)
echo This is a batch file in build stage我有一个用PowerShell编写的非常紧凑的构建任务。我的团队现在正在试验Jenkins Pipeline特性,如果能将ps构建代码分成几个阶段(构建核心、构建模块、测试、覆盖等),那就太好了。我们可以很容易地通过为每个阶段创建函数来做到这一点,但效率会很低(加载ps模块...)
发布于 2017-03-03 18:49:30
我建议您使用另一种方法:您可以在Powershell脚本中将不同的步骤定义为CmdLet:
function step_1()
{
[CmdletBinding(SupportsShouldProcess=$true)]
param ()
Write-Verbose "step 1"
}
function step_2()
{
[CmdletBinding(SupportsShouldProcess=$true)]
param ()
Write-Verbose "step 2"
}然后,您可以定义Powershell方法,就像我描述的那样:To call a PowerScript from the Groovy-Script
在您的Groovy管道脚本中:
node ('MyWindowsSlave') {
stage ('Stage 1') {
PowerShell(". '.\\all-stages.ps1'; stage1 -Verbose")
}
stage ('Stage 2') {
PowerShell(". '.\\all-stages.ps1'; stage2 -Verbose")
}
}您还可以考虑将Groovy脚本拆分为几个文件,让powershell开发人员使用他们自己的Groovy子脚本。
致以问候。
发布于 2017-12-12 16:55:39
您可以使用输入步骤(https://jenkins.io/doc/pipeline/steps/pipeline-input-step/)等待用户响应以继续管道:
一个简单的“是”或“否”,一个多项选择,一个密码确认...


例如,您可以使用ldap组来控制谁可以响应此输入事件。
https://stackoverflow.com/questions/40089244
复制相似问题