-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-merge
75 lines (69 loc) · 2.29 KB
/
Jenkinsfile-merge
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
pipeline {
//options {}
agent any
parameters {
string(defaultValue: 'http://pythonhttp.lisa18.hutty.uk', description: 'the URL which should be visited', name: 'TARGET_URL')
}
environment {
AWS_DEFAULT_REGION = 'us-east-1'
}
stages {
stage('setup') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: env.GIT_COMMIT]],
userRemoteConfigs: [[
credentialsId: "dhutty-github-token",
url: env.GIT_URL
]]
])
dir("${WORKSPACE}/tf") {
withCredentials([
usernamePassword(
credentialsId: 'dhutty-aws-creds',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
),
]) { sh "terraform init"
}
}
}
}
stage('plan') {
steps {
dir("${WORKSPACE}/tf") {
withCredentials([
usernamePassword(
credentialsId: 'dhutty-aws-creds',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
),
]) { sh "terraform plan"
}
}
}
}
stage('deploy') {
steps {
dir("${WORKSPACE}/tf") {
withCredentials([
usernamePassword(
credentialsId: 'dhutty-aws-creds',
usernameVariable: 'AWS_ACCESS_KEY_ID',
passwordVariable: 'AWS_SECRET_ACCESS_KEY'
),
]) {
sh "terraform apply -auto-approve"
}
}
}
}
stage('e2e_test') {
steps {
sh "virtualenv -p python3 venv; pip install httpie"
sh "source venv/bin/activate; http http://${TARGET_URL}"
}
}
}
}
// vi:syntax=groovy