小编Ham*_*thy的帖子

Jenkins SSH Pipeline 步骤 - 需要终端来读取密码

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

我一直在使用Jenkins SSH Pipeline Steps 插件,它允许我通过 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: …
Run Code Online (Sandbox Code Playgroud)

deployment jar jenkins docker jenkins-pipeline

2
推荐指数
1
解决办法
5539
查看次数

标签 统计

deployment ×1

docker ×1

jar ×1

jenkins ×1

jenkins-pipeline ×1