【问题标题】:Why Jenkins lost connection with Tomcat server为什么 Jenkins 失去了与 Tomcat 服务器的连接
【发布时间】:2021-02-03 23:36:39
【问题描述】:

我的 Jenkins 与 Tomcat 服务器失去了连接。我还在 Jenkins 凭据中添加了私钥。

这是我的 'Deploy-toTomcat' 阶段的 jenkinsfile

            steps {
              sshagent(['tomcat']) {
                 sh 'scp -o StrictHostKeyChecking=no target/*.war 
                 ubuntu@35.239.69.247:/home/nat/prod/apache-tomcat-9.0.41/webapps/webapp.war'
                 }      
             }       
        }

这是我尝试在 Jenkins 中构建管道时的错误

+ scp -o StrictHostKeyChecking = no target/WebApp.war ubuntu@35.239.69.247:/home/nat/prod/apache-tomcat-9.0.41/webapps/webapp.war
command-line line 0: missing argument.
lost connection
script returned exit code 1

错误

$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 139377 killed;
[ssh-agent] Stopped.

我也输入了命令chmod 777 webapps 我正在点击此链接 https://www.youtube.com/watch?v=dSMSHGoHVJY&list=PLjNII-Jkdjfz5EXWlGMBRk63PC8uJsHMo&index=7 来部署 tomcat。

希望知道的人能回答我关于如何部署到 tomcat 的问题。我测试构建管道的源代码也来自 https://github.com/cehkunal/webapp.git。谢谢。

【问题讨论】:

    标签: jenkins tomcat jenkins-pipeline


    【解决方案1】:

    错误是因为它没有识别出哪个是授权密钥。我做了什么

    1. 删除 ./ssh 文件中所有以前的键,
    2. ssh-keygen -t rsa
    3. mv id_rsa.pub 授权密钥
    4. chmod 0600 /home/username/.ssh/authorized_keys
    5. chmod 0700 /home/username/.ssh
    6. 猫 id_rsa

    最后在 Jenkins 管理凭据中插入 id_rsa。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-13
      • 2012-08-31
      • 1970-01-01
      • 1970-01-01
      • 2017-08-07
      • 2010-12-25
      • 1970-01-01
      • 2020-06-19
      相关资源
      最近更新 更多