记一次完成coding运维平台私有服务器部署流程

pipeline {
  agent any
  stages {
    stage('检出') {
      steps {
        checkout([
          $class: 'GitSCM',
          branches: [[name: GIT_BUILD_REF]],
          userRemoteConfigs: [[
            url: GIT_REPO_URL,
            credentialsId: CREDENTIALS_ID
          ]]])
        }
      }
    stage('toggle Node.js version') {
      steps {
        sh 'rm -rf /usr/lib/node_modules/npm/'
        dir ('/root/.cache/downloads') {
          sh 'wget -nc "https://nodejs.org/download/release/v14.17.4/node-v14.17.4-linux-x64.tar.xz" -O node-v14.17.4-linux-x64.tar.xz | true'
          sh 'tar -xf node-v14.17.4-linux-x64.tar.xz -C /usr --strip-components 1'
        }
        sh 'node -v'
      }
     }

    stage('toggle npm version') {
      steps {
        sh 'npm -g install npm@8.5.5'
        sh 'npm -v'
      }
     }

      stage('安装依赖') {
        steps {
          echo '安装依赖...'
          sh 'ls'
          sh '''
            echo hello CODING 
            ls
            pnpm install
            ls
            echo \'install success\'
            npm run build
            echo \'build success\'
            tar -zcvf dist.tar.gz dist
            echo \'tar succcess\'
            ls'''
          echo '依赖安装成功'
        }
      }

      stage('部署') {
        steps {
           script {
              def remote = [:]
              remote.name = "root"
              remote.host = "你的ip"
              remote.port = IP端口
              // SSH 登陆用户名
              remote.user = '服务器账号'
              remote.password= "服务器密码"
              remote.allowAnyHosts = true
              sshPut remote: remote, from: '/root/workspace/dist.tar.gz', into: '/datavg/fe/clinic'
              sshCommand remote: remote, command: "tar -zxvf /datavg/fe/clinic/dist.tar.gz --strip-components 1 -C /datavg/fe/clinic" 
              sshCommand remote: remote, command: '''
              cd /datavg/fe/clinic
              rm dist.tar.gz
              '''
        }
          echo '部署完成'
        }
      }

    }
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值