-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathJenkinsfile
92 lines (71 loc) · 2.42 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
#!/usr/bin/env groovy
node('master') {
try {
stage('Commit') {
// Checkout SCM
checkout scm
withEnv(['PATH=/sbin:/usr/sbin:/bin:/usr/bin:/var/lib/jenkins/bin:/usr/local/bin']) {
// Configure Workspace
sh 'which bundle || gem install bundler'
sh 'bundle install'
// sh 'bundle info cfn-nag | grep Path | cut -f2 -d" " > cfn-nag.path'
// Build
sh 'rake commit:build'
// // Configure CFN_Nag
// sh 'rake commit:cfn_nag:rules'
// Static Analysis
sh 'rake commit:static_analysis'
// Security / Static Analysis
sh 'rake commit:security_test'
// Unit Tests for CFN_NAG custom rules
sh 'rake commit:cfn_nag_unit_tests'
}
}
stage('Acceptance') {
def region = env.AWS_REGION == null ? 'us-east-1' : env.AWS_REGION
withEnv(['PATH=/sbin:/usr/sbin:/bin:/usr/bin:/var/lib/jenkins/bin:/usr/local/bin']) {
// Create Acceptance Environment
sh 'rake acceptance:create_environment'
// Infrastructure Tests
sh 'rake acceptance:infrastructure_test'
// Integration Tests
sh 'rake acceptance:integration_test'
// Security / Integration Tests
sh 'rake acceptance:security_test'
}
}
stage('Capacity') {
withEnv(['PATH=/sbin:/usr/sbin:/bin:/usr/bin:/var/lib/jenkins/bin:/usr/local/bin']) {
// Security / Penetration Tests
sh 'rake capacity:security_test'
// Capacity Test
sh 'rake capacity:capacity_test'
}
}
stage('Deployment') {
withEnv(['PATH=/sbin:/usr/sbin:/bin:/usr/bin:/var/lib/jenkins/bin:/usr/local/bin']) {
// Deployment
sh 'rake deployment:production'
// Deployment Verification
sh 'rake deployment:smoke_test'
}
}
}
catch(err) {
handleException(err)
}
}
// Exception helper
def handleException(Exception err) {
println(err.toString());
println(err.getMessage());
println(err.getStackTrace());
/* Mail currently not configured
mail body: "project build error is here: ${env.BUILD_URL}" ,
from: '[email protected]',
replyTo: '[email protected]',
subject: 'AWS DevSecOps Workshop Pipeline Build Failed',
to: '[email protected]'
*/
throw err
}