Jenkinsfile
2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!groovy
pipeline {
agent { label 'master' }
parameters {
choice(name:'clusterId',choices:'aws\nyoho-web-gray\nyoho-ops\nyoho-web\nyoho-media\n', description: '集群的信息')
string(name:'serviceName', defaultValue: 'yoho-app-web', description: '服务名称 ')
string(name:'containerName', defaultValue: 'yoho-app-web', description: '容器名称')
string(name:'imageInfo', defaultValue: 'yohobuy-core/yohobuywap-node:hotfix-share-20181221134254', description: '镜像版本')
choice(name:'deployEnv',choices:'aws\nqcloud\nall\n', description: '部署的集群信息')
}
//常量参数,初始确定后一般不需更改
environment{
CRED_ID='2cb1761b-b258-4e3b-843f-8f0dab16d770'
QA_EMAIL='jimi.ji@yoho.cn'
AWS_IMAGE='860721417875.dkr.ecr.cn-north-1.amazonaws.com.cn'
QCLOUD_IMAGE='ccr.ccs.tencentyun.com'
}
options {
//保持构建的最大个数
buildDiscarder(logRotator(numToKeepStr: '20'))
}
stages {
stage('Define para'){
steps{
script {
echo "print the para projectName is : ${params.clusterId}......"
echo "print the para projectGitGroup is : ${params.serviceName}......"
echo "print the para deployName is : ${params.containerName}......"
echo "print the para branch is : ${params.imageInfo}......"
echo "print the para isNeedCdn is : ${params.deployEnv}......"
}
}
}
stage('qcloud deploy'){
steps{
script {
println "begin upload to cdn"
if(params.deployEnv=='qcloud' || params.deployEnv=='all'){
//切换kubectl的认证
def pyworkdir="${env.WORKSPACE}/Docker-Image-Deplopy/qcloud/qcloudDeploy.py"
sh "python ${pyworkdir} ${params.clusterId} ${params.serviceName} ${params.containerName} ${params.imageInfo}"
}else {
println "qcloud this no need deploy"
}
}
}
}
stage('aws deploy'){
steps{
script {
println "begin upload to cdn"
if(params.deployEnv=='aws' || params.deployEnv=='all'){
//切换kubectl的认证
def shellworkdir="${env.WORKSPACE}/Docker-Image-Deplopy/aws/awsdeploy.sh"
sh "sh ${shellworkdir} ${params.serviceName} ${params.imageInfo}"
}else {
println "aws this no need restart"
}
}
}
}
}
post {
always {
echo "clean up our workspace"
deleteDir() /* clean up our workspace */
}
}
}