Jenkinsfile
2.29 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
#!groovy
pipeline {
agent { label 'master' }
parameters {
string(name:'clusterId', defaultValue: 'yoho-web-gray', 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: '镜像版本')
string(name:'deployEnv', defaultValue: 'qcloud', description: '部署环境 qcloud,aws,all')
}
//常量参数,初始确定后一般不需更改
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的认证
sh '''echo "begin execute shell"
/usr/local/bin/kubectl get pods
num=1
while [ $i -le 10 ]
do
let num=num+1
echo $num
done'''
}else {
println "qcloud this no need restart"
}
}
}
}
}
post {
always {
echo "clean up our workspace"
deleteDir()/* clean up our workspace */
}
}
}