Docker Jenkins SSH管道步骤-需要终端读取密码

Docker Jenkins SSH管道步骤-需要终端读取密码,docker,jenkins,deployment,jar,jenkins-pipeline,Docker,Jenkins,Deployment,Jar,Jenkins Pipeline,最近,我一直在和Docker/Jenkins闲逛,以了解更多有关CI/CD工作流的信息。我的目标是创建一个从github推送、构建代码并将JAR文件发布到远程服务器以便进一步部署的流程 我一直在使用,它允许我通过SSH连接到远程服务器来执行命令 以下是部署阶段,涉及我要执行的命令: stage("Deploying") { steps { script { withCredenti

最近,我一直在和Docker/Jenkins闲逛,以了解更多有关CI/CD工作流的信息。我的目标是创建一个从github推送、构建代码并将JAR文件发布到远程服务器以便进一步部署的流程

我一直在使用,它允许我通过SSH连接到远程服务器来执行命令

以下是部署阶段,涉及我要执行的命令:

stage("Deploying") {
            steps {
                script {
                    withCredentials([sshUserPrivateKey(credentialsId: 'e48b15ad-0f5e-4f07-8706-635c5250fa29', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'jenkins')]) {
                      remote.user = jenkins
                      remote.identityFile = identity

                      sshCommand remote: remote, command: 'cd Winston-Bot/; sudo ./kill_winston.sh'
                      sshCommand remote: remote, command: 'rm Winston-Bot/*.jar', failOnError:'false'
                      sshCommand remote: remote, command: 'rm -rf Winston-Bot/src', failOnError:'false'
                      sshPut remote: remote, from: "target/Winston-Bot-${VERSION}-jar-with-dependencies.jar", into: 'Winston-Bot/'
                      sshPut remote: remote, from: "src", into: 'Winston-Bot/'
                      sshCommand remote: remote, command: "echo ${VERSION} > Winston-Bot/version.txt"
                    }
                }
            }
        }
执行
cd-Winston-Bot/;sudo./kill_winston.sh
我收到以下错误:

Executing command on ****[51.159.152.230]: cd Winston-Bot/; sudo ./kill_winston.sh sudo: false

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
Failed command ****#15 with status 1: cd Winston-Bot/; sudo ./kill_winston.sh
我已经使用以下代码将jenkins用户组添加到
etc/sudoers

jenkins ALL=(ALL) NOPASSWD: /var/lib/jenkins/Winston-Bot/.kill_winston.sh
当以用户
jenkins
的身份通过终端登录到我的远程服务器时,脚本执行得非常好,不需要密码。有人能帮我解决这个问题吗