forked from Blazemeter/taurus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
97 lines (94 loc) · 3.5 KB
/
Jenkinsfile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@Library("jenkins_library") _
pipeline {
agent any
options {
timestamps()
skipDefaultCheckout()
}
stages {
stage('Checkout') {
steps {
cleanWs()
script {
scmVars = checkout scm
commitHash = scmVars.GIT_COMMIT
tagName = sh(returnStdout: true, script: "git tag --points-at HEAD").trim()
isRelease = !tagName.isEmpty()
IMAGE_TAG = env.JOB_NAME + "." + env.BUILD_NUMBER
IMAGE_TAG = IMAGE_TAG.toLowerCase()
imageName = "blazemeter/taurus"
extraImageTag = isRelease ? "${imageName}:${tagName} -t ${imageName}:latest" : "${imageName}:unstable"
}
}
}
stage("Docker Image Build") {
steps {
sh """
docker build -t ${JOB_NAME} -t ${extraImageTag} .
"""
}
}
stage("Integration Tests") {
steps {
sh """
docker run -v `pwd`:/bzt-configs -v `pwd`/integr-artifacts:/tmp/artifacts ${JOB_NAME} -sequential examples/all-executors.yml
"""
}
}
stage("Docker Image Push") {
steps {
withDockerRegistry([ credentialsId: "dockerhub-access", url: "" ]) {
sh "docker push ${imageName}"
}
}
}
stage("Create Artifacts") {
steps {
script {
sh """
sed -ri "s/OS: /Rev: ${commitHash}; OS: /" bzt/cli.py
"""
if (!isRelease) {
sh """
sed -ri "s/VERSION = .([^\\"]+)./VERSION = '\\1.${BUILD_NUMBER}'/" bzt/__init__.py
"""
}
sh """
docker run --entrypoint /bzt-configs/build-artifacts.sh -v `pwd`:/bzt-configs ${JOB_NAME} ${BUILD_NUMBER}
"""
}
archiveArtifacts artifacts: 'dist/*.whl', fingerprint: true
}
}
stage("Deploy site") {
steps {
sh """
docker build -t deploy-image -f site/Dockerfile.deploy .
"""
script {
PROJECT_ID="blazemeter-taurus-website-prod"
withCredentials([file(credentialsId: "${PROJECT_ID}", variable: 'CRED_JSON')]) {
def WORKSPACE_JSON = 'Google_credentials.json'
def input = readJSON file: CRED_JSON
writeJSON file: WORKSPACE_JSON, json: input
sh """
docker run --entrypoint /bzt/site/deploy-site.sh \
-e KEY_FILE=${WORKSPACE_JSON} \
-e PROJECT_ID=${PROJECT_ID} \
-e BUILD_NUMBER=${BUILD_NUMBER} \
-u root \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/bzt -t deploy-image \
${isRelease}
"""
}
}
}
}
}
post {
always {
smartSlackNotification(channel: "taurus-dev", buildStatus:currentBuild.result ?: 'SUCCESS')
}
}
}