Jenkins Powershell写入控制台

Jenkins Powershell写入控制台,powershell,jenkins,jenkins-pipeline,Powershell,Jenkins,Jenkins Pipeline,我有一份叫jenkins的工作,它调用powershell文件。当我从freestyle项目中使用它时,它会在控制台输出中显示powershell执行。切换到管道作业后,我不再看到输出 目前,我的管道如下所示: pipeline { stages { stage ('Deploy To Dev') { steps { powershell '"%WORKSPA

我有一份叫jenkins的工作,它调用powershell文件。当我从freestyle项目中使用它时,它会在控制台输出中显示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
                }
            }
        }
    }
}
但这给了:

第123行第6列应为步骤。def味精= powershell(返回stdout:true,脚本: “%WORKSPACE%\SpearsLoad\Scripts\CIDeployToDev.Ps1””


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

您需要将管道执行打包到
script
部分,因为您试图在以下内容中使用脚本语法:


对于来这里寻找答案的人,我需要指出,代码实际上有3个独立的问题:

  • 根据公认的答案,缺少脚本部分
  • 由于未正确调用,powershell未实际运行
  • 由于%WORKSPACE%变量中存在空格,powershell未运行
  • 最后,我选择了:

    script {
        def msg = powershell(returnStdout: true, script: " & './SpearsLoad\\Scripts\\CIDeployToDev.Ps1'")
        println msg
            }  
    
    这确实有效

    我使用 写主机“我的消息”
    在powershell中。这将显示在日志中。

    谢谢,我想这可能是一个根本性的误解,干杯:)
    script {
        def msg = powershell(returnStdout: true, script: " & './SpearsLoad\\Scripts\\CIDeployToDev.Ps1'")
        println msg
            }