This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
65 lines (60 loc) · 2.17 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
node('docker') {
try {
properties([disableConcurrentBuilds()])
repository = "quay.io/aspenmesh/bookinfo-private"
branchName = env.BRANCH_NAME.toLowerCase()
version = "$branchName-${env.BUILD_ID}"
stage('Checkout') {
checkout scm
}
stage('Build and Push') {
docker.withRegistry('https://quay.io', 'quay-infrajenkins-robot-creds') {
sh "./build_push_update_images.sh $repository $version"
}
}
tmpDir = sh(script: "mktemp -d --tmpdir=$WORKSPACE", returnStdout: true).trim()
experimentNamespace = "bookinfo-dev-$branchName"
stage('Deploy') {
if ("$branchName" != 'master') {
withEnv(["BINDIR=$tmpDir"]) {
sh '''
kubectl=$BINDIR'/kubectl'
curl -o $kubectl -L 'https://storage.googleapis.com/kubernetes-release/release/v1.7.11/bin/linux/amd64/kubectl'
chmod +x $kubectl
'''
withCredentials([file(credentialsId: 'dummy_k8s_cluster_jenkins_config', variable: 'KUBECONFIG')]) {
sh "./deploy.sh $repository $version $experimentNamespace"
}
}
} else {
sh "echo 'Skipping deploy for master branch' "
}
}
experimentName = "bookinfo-$branchName"
baselineNamespace = "default"
service = "productpage"
stage('Aspen Experiment') {
if (env.BRANCH_NAME != 'master') {
withEnv(["BINDIR=$tmpDir"]) {
copyArtifacts(projectName: 'apiserver/master',
filter: '_build/canonical/cross/aspenctl-linux-amd64',
selector: lastSuccessful(), target: "$tmpDir", flatten: true)
sh '''
aspenctl=$BINDIR'/aspenctl'
mv $BINDIR'/aspenctl-linux-amd64' $aspenctl
chmod +x $aspenctl
'''
withCredentials([string(credentialsId: 'dummy_user_agent_token', variable: 'TOKEN')]) {
sh "./create-experiment.sh $experimentName $baselineNamespace $experimentNamespace $service"
}
}
} else {
sh "echo 'Skipping aspen experiment for master branch' "
}
}
} catch (e) {
throw e
} finally {
sh "if [ -d $tmpDir ]; then rm -r $tmpDir; fi "
}
}