无法在 jenkinsfile 中执行 shell 命令

时间:2021-06-10 23:41:20

标签: jenkins groovy

出于某种原因,当我在我的 Jenkinsfile 中为声明性管道执行以下操作时,

script{
                    withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: "${env.AWS_DEPLOYMENT_CREDENTIALS}"]]){
                        echo "==================\n\nDeploying.\n\n=================="
                        String scriptOutput =  sh(
                                    script: 'aws apigateway get-rest-api --rest-api-id <some-id>',
                                    returnStdout: true
                                    ).trim()
                            echo "scriptOutput: ${scriptOutput}"

                    }
                }

我得到:

process apparently never started
(running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)

带有 sh 的命令永远不会运行,但代码正确执行 Deploying

  1. 持久任务插件是 1.36。 [https://stackoverflow.com/questions/58346984/how-to-fix-process-apparently-never-started-in-error-in-jenkins-pipeline]
  2. 当我使用 org.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true 在脚本控制台中复制并粘贴整个 groovy 文件时 我得到: No signature of method: Script1.pipeline() is applicable for argument types: (Script1$_run_closure1) values:

注意:完全相同的脚本适用于另一个 jenkins 大师。我不确定应该查看哪个版本/插件来解决该问题。

0 个答案:

没有答案