forked from coreos/tectonic-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
141 lines (127 loc) · 3.77 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* Tips
1. Keep stages focused on producing one artifact or achieving one goal. This makes stages easier to parallelize or re-structure later.
1. Stages should simply invoke a make target or a self-contained script. Do not write testing logic in this Jenkinsfile.
3. CoreOS does not ship with `make`, so Docker builds still have to use small scripts.
*/
def creds = [
file(credentialsId: 'tectonic-license', variable: 'TF_VAR_tectonic_license_path'),
file(credentialsId: 'tectonic-pull', variable: 'TF_VAR_tectonic_pull_secret_path'), [
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'tectonic-aws',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
]
]
pipeline {
agent {
docker {
image 'quay.io/coreos/tectonic-builder:v1.10'
label 'worker'
}
}
options {
timeout(time:60, unit:'MINUTES')
timestamps()
buildDiscarder(logRotator(numToKeepStr:'20'))
}
environment {
GO_PROJECT = '/go/src/github.com/coreos/tectonic-installer'
MAKEFLAGS = '-j4'
}
stages {
stage('TerraForm: Syntax Check') {
steps {
sh """#!/bin/bash -ex
make structure-check
"""
}
}
stage('Generate docs') {
steps {
sh """#!/bin/bash -ex
# Prevent fatal: You don't exist. Go away! git error
git config --global user.name 'jenkins tectonic installer'
git config --global user.email '[email protected]'
go get github.com/segmentio/terraform-docs
make docs
git diff --exit-code
"""
}
}
stage('Generate examples') {
steps {
sh """#!/bin/bash -ex
# Prevent fatal: You don't exist. Go away! git error
git config --global user.name 'jenkins tectonic installer'
git config --global user.email '[email protected]'
go get github.com/s-urbaniak/terraform-examples
make examples
git diff --exit-code
"""
}
}
stage('Installer: Build & Test') {
steps {
checkout scm
sh "mkdir -p \$(dirname $GO_PROJECT) && ln -sf $WORKSPACE $GO_PROJECT"
sh "go get github.com/golang/lint/golint"
sh """#!/bin/bash -ex
go version
cd $GO_PROJECT/installer
make clean
make tools
make build
make lint
make test
"""
stash name: 'installer', includes: 'installer/bin/linux/installer'
stash name: 'sanity', includes: 'installer/bin/sanity'
}
}
stage("Smoke Tests") {
steps {
parallel (
"TerraForm: AWS": {
unstash 'installer'
unstash 'sanity'
withCredentials(creds) {
timeout(30) {
sh '${WORKSPACE}/tests/smoke/aws/smoke.sh plan vars/aws.tfvars'
sh '${WORKSPACE}/tests/smoke/aws/smoke.sh create vars/aws.tfvars'
sh '${WORKSPACE}/tests/smoke/aws/smoke.sh test vars/aws.tfvars'
}
timeout(10) {
sh '${WORKSPACE}/tests/smoke/aws/smoke.sh destroy vars/aws.tfvars'
}
}
},
"TerraForm: AWS-experimental": {
unstash 'installer'
unstash 'sanity'
withCredentials(creds) {
timeout(5) {
sh '${WORKSPACE}/tests/smoke/aws/smoke.sh plan vars/aws-exp.tfvars'
}
}
}
)
}
post {
failure {
unstash 'installer'
withCredentials(creds) {
timeout(10) {
sh '${WORKSPACE}/tests/smoke/aws/smoke.sh destroy vars/aws.tfvars'
}
}
}
}
}
}
post {
always {
// Cleanup workspace
deleteDir()
}
}
}