Jenkins,用 Jenkinsfile 连接远程服务器并用 pm2 部署

问题描述

如何使其正常工作

需要连接远程服务器,到项目路径pull然后通过jenkins部署

    agent any
    stages {
       stage('server') {
          steps {
             echo 'Connect server'
             sh 'ssh ubuntu@xx.xxx.xx.x'
             sh 'cd /var/www/node/projetct'
          }
       stage('modules') {
          steps {
             echo 'Install app modules'
             sh 'yarn install'
          }
       }
       stage('build') {
          steps {
             echo 'Building app...'
             sh 'yarn build:shared && yarn build:web'
          }
       }
       stage('deploy') {
           steps {
               echo 'Starting app with PM2'
               sh 'pm2 start ecosystem.config.js --env production'
               updateGitlabCommitStatus name: 'test',state: 'pending'
               echo 'test step goes here'
               updateGitlabCommitStatus name: 'test',state: 'success'

           }
       }
    }
 }```

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)