-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipelinefile
42 lines (40 loc) · 1.79 KB
/
pipelinefile
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
pipeline{
agent any
stages {
stage('init'){
steps{
echo "============================< 开始构建 >========================================="
git branch: "${BRANCH_NAME}", credentialsId: '1111-2222-11111-11111-111111', url: "${GIT_PATH}"
script {
build_tag = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
imageTag = "${imageName}-${build_tag}"
}
echo "${build_tag}"
}
}
stage('Maven Build') {
steps {
sh 'mvn -f pom.xml clean package -Denv=pre -U -DskipTests=true'
}
}
stage("docker image build"){
steps{
echo "${imageTag}"
sh 'tar -C $ProjectPath -czf ${appName}.tgz ./$appName'
sh 'ansible docker-registry -m unarchive -a "src=${appName}.tgz dest=/var/jenkins/build_images/public_dev/"'
sh "ansible docker-registry -m command -a '/bin/sh /var/jenkins/scripts/build_docker_images.sh ${appName} dev 1.8.0_191 ${imageTag}'"
}
}
stage("create helm package"){
steps{
sh 'ansible devcluster -m command -a "/bin/bash /home/admin/helmTemplate/createHelm.sh $appVersion $appName dev"'
}
}
stage("helm install"){
steps{
sh 'ansible devcluster -m command -a "helm repo update"'
sh "ansible devcluster -m command -a 'helm upgrade --force --recreate-pods ${appName} localself-repo/${appName} --install --set image.imageName=${imageTag},service.port=${port},livenessProbe.port=${port},ports.containerPort=${port},iptype=${iptype},resources.limits.memory=1048Mi'"
}
}
}
}