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 '部署完成'
}
}
}
}
记一次完成coding运维平台私有服务器部署流程
最新推荐文章于 2024-09-05 03:31:27 发布