jenkins配置

 branch: "dev"        切换分支

$WORKSPACE: /var/lib/jenkins/workspace/jenkins任务名

dest_passwd=服务器密码   变量

sudo sshpass -p $dest_passwd ssh [email protected] -tt rm -rf /data/patent/*:删除文件/data/patent/*

sudo sshpass -p $dest_passwd scp -r -o StrictHostKeyChecking=no $WORKSPACE/ant-design-vue-jeecg/dist/*  [email protected]:/data/patent:设置密码  将dist文件移动到patent目录下

pipeline {
  agent any
  stages {
        stage("Gitlab"){
            steps{
                script{
                    git branch: "dev", credentialsId: '12313121231213123123123', url: 'http://192.168.20.168/patent/patent-admin.git'
                }
            }
        }
       
        stage("Build") {
            steps {
                script{
                    sh '''
                    cd $WORKSPACE/ant-design-vue-jeecg
                    cnpm install
                    cnpm run build
                    '''
                }
            }
        }
        
         stage("Release") {
            steps {
                script{
                    sh '''
                    dest_passwd=服务器密码
                    sudo sshpass -p $dest_passwd ssh [email protected] -tt rm -rf /data/patent/*
                    sudo sshpass -p $dest_passwd scp -r -o StrictHostKeyChecking=no $WORKSPACE/ant-design-vue-jeecg/dist/*  [email protected]:/data/patent
                    '''
                }
            }
        }
       
   }
   
}

你可能感兴趣的:(jenkins,运维)