gpt4 book ai didi

powershell - Jenkins Powershell 写入控制台

转载 作者:行者123 更新时间:2023-12-02 22:33:40 30 4
gpt4 key购买 nike

我有一个调用 powershell 文件的 jenkins 工作。当我从自由式项目中使用它时,它会在控制台输出中显示 powershell 执行情况。将其切换到管道作业后,我不再看到输出。

目前我的管道看起来像这样:

 pipeline 
{
stages
{
stage ('Deploy To Dev')
{
steps
{
powershell '"%WORKSPACE%\\SpearsLoad\\Scripts\\CIDeployToDev.Ps1"'
}
}
}
}

但我没有记录 powershell 步骤。

按照文档,我尝试将舞台更改为:
pipeline 
{
stages
{
stage ('Deploy To Dev')
{
steps
{
node('Deploy the SSIS load')
{
//Deploy the SSIS load
def msg = powershell(returnStdout: true, script: '"%WORKSPACE%\\SpearsLoad\\Scripts\\CIDeployToDev.Ps1"')
println msg
}
}
}
}
}

但这给出了:

Expected a step @ line 123, column 6. def msg = powershell(returnStdout: true, script: '"%WORKSPACE%\SpearsLoad\Scripts\CIDeployToDev.Ps1"')



我觉得我错过了一些非常基本的东西。我究竟做错了什么 ?

最佳答案

您需要将管道执行包装到 script 中部分,因为您试图在 declarative pipeline 中使用脚本化语法:

script {
//Deploy the SSIS load
def msg = powershell(returnStdout: true, script: '"%WORKSPACE%\\SpearsLoad\\Scripts\\CIDeployToDev.Ps1"')
println msg
}

关于powershell - Jenkins Powershell 写入控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54476655/

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