-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (61 loc) · 2.01 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
pipeline {
environment {
registry = "victorgrubio/udacity-devops-final-project"
registryCredential = 'dockerhub'
dockerImage = ''
}
agent any
stages {
stage('Build'){
steps{
withEnv(["HOME=${env.WORKSPACE}"]) {
sh 'pip3 install --user pylint flask'
}
}
}
stage('Lint'){
steps{
withEnv(["HOME=${env.WORKSPACE}"]) {
sh 'python3 -m pylint app.py'
}
}
}
stage('Build docker'){
steps{
withEnv(["HOME=${env.WORKSPACE}"]) {
sh 'hadolint Dockerfile'
}
script {
docker.withRegistry( '', registryCredential) {
dockerImage = docker.build registry + ":1.0.2"
dockerImage.push()
}
}
}
}
stage('Validate CloudFormation Template'){
steps{
withAWS(region:'us-east-1', credentials:'9aee3fa1-090b-4274-a588-17d54bad0cf5') {
script{
def response_network = cfnValidate(file:'cloud-formation/network.yml')
echo "template description: ${response_network.description}"
def response_servers = cfnValidate(file:'cloud-formation/servers.yml')
echo "template description: ${response_servers.description}"
}
}
}
}
stage('Create CloudFormation Stacks'){
steps{
withAWS(region:'us-east-1', credentials:'9aee3fa1-090b-4274-a588-17d54bad0cf5') {
script{
def output_network_stack = cfnUpdate(stack:'final-project-network', file:'cloud-formation/network.yml', timeoutInMinutes:30, pollInterval: 15000)
def output_server_stack = cfnUpdate(stack:'final-project-servers', file:'cloud-formation/servers.yml', paramsFile:'cloud-formation/server-parameters.json', timeoutInMinutes:30, pollInterval:30000)
def outputs = cfnDescribe(stack:'final-project-network')
echo "Server stack description: ${outputs}"
}
}
}
}
}
}