123456789101112131415161718192021222324252627282930313233343536373839404142 |
- pipeline {
- agent any
- options {
- timeout(time: 10, unit: 'MINUTES')
- }
- stages {
- stage('检出') {
- steps {
- checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
- userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
- }
- }
- stage('安装依赖') {
- steps {
- echo '安装依赖中...'
- sh 'cd api && npm i'
- sh 'cd dashboard && npm i'
- echo '安装依赖完成.'
- }
- }
- stage('部署') {
- steps {
- echo '部署中...'
- withCredentials([string(credentialsId: '328ecbdc-6b00-465b-9a0a-f5521cf561cc', variable: 'TENCENT_CLOUD_CREDENTIAL')]) {
- script{
- if (env.TENCENT_CLOUD_CREDENTIAL == '{}') {
- error('临时授权已失效,请前往凭据管理重新授权。')
- }
- }
- sh 'echo "${TENCENT_CLOUD_CREDENTIAL}" > .env_temp'
- sh 'serverless | tee console.log'
- withCredentials([usernamePassword(credentialsId: "${env.CCI_CURRENT_PROJECT_COMMON_CREDENTIALS_ID}", passwordVariable: 'password', usernameVariable: 'userName')]) {
- // 发公告
- sh 'echo content=$(grep url console.log | head -1) | curl --user ${userName}:${password} https://${CCI_CURRENT_TEAM}.coding.net/api/project/${PROJECT_ID}/tweet -d@-'
- }
- sh 'rm .env_temp'
- }
- echo '部署完成'
- }
- }
- }
- }
|