微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。