You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

56 lines
2.2 KiB

pipeline {
agent any
//parameters {
//string(name:'publish_server', defaultValue: '195', description: '部署服务器')
//}
stages {
// 获取或更新最新代码
stage('check out') {
steps {
script{
def gitea_url
if("${gitea_server}" == "136Git")
{
gitea_url = "$local136_gitea_url"
}
if("${gitea_server}" == "aliyunGitea")
{
gitea_url = "$aliyun_gitea_url"
}
echo "================${gitea_url}"
// git 通过 用户名、密码认证
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: "${gitea_server}", url: gitea_url]]])
echo "check out OK"
}
}
}
stage('build') {
steps {
nodejs('node10.19') {
sh '''
cd /root/.jenkins/workspace/${single_project_name}
rm -rf dist
npm config set registry https://registry.npmmirror.com
npm install
npm install echarts@4.9.0
npm run build
#cd dist
#JENKINS_NODE_COOKIE=dontKillMe nohup npm start &
'''
}
}
}
stage('publish') {
steps {
echo "copy file to nginx server"
sh '''
pwd
'''
sshPublisher(publishers: [sshPublisherDesc(configName: "$publish_server", transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: "/data/openresty/nginx/html/", remoteDirectorySDF: false, removePrefix: "dist", sourceFiles: "dist/**/*")], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
echo "copy file to nginx server end"
}
}
}
}