-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
76 lines (75 loc) · 2.63 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
pipeline {
agent any
stages {
stage('Integration') {
when{
expression {
return env.BRANCH_NAME != 'master';
}
}
steps {
sh 'git pull'
sh 'find ./Step*/ \\( -name "*.yml" -o -name "*.yaml" \\) -exec yamllint -c ./my_yamllint_config.yml {} +'
sh 'ansible-playbook -i hosts Step2-config/config_delivery.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/bgp_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/ping_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/vlan_test.yml'
}
}
stage('Delivery') {
when{
expression {
return env.BRANCH_NAME != 'master';
}
}
steps {
sh 'git pull origin master'
sh 'find ./Step*/ \\( -name "*.yml" -o -name "*.yaml" \\) -exec yamllint -c ./my_yamllint_config.yml {} +'
sh 'ansible-playbook -i hosts Step2-config/config_delivery.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/bgp_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/ping_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/vlan_test.yml'
}
}
stage('Deployment Approval') {
when{
expression {
return env.BRANCH_NAME != 'master';
}
}
steps {
input """
Are you you sure to proceed with Prod Depyloment?
Local branch will be pushed to the GitHub and this will trigger a deployment to the Live Network
"""
sh 'whoami'
sh 'git push origin HEAD:master'
}
}
stage('Deployment') {
when{
expression {
return env.BRANCH_NAME == "NetLab_master";
}
}
steps {
sh 'find ./Step*/ \\( -name "*.yml" -o -name "*.yaml" \\) -exec yamllint -c ./my_yamllint_config.yml {} +'
sh 'ansible-playbook -i hosts Step2-config/config_delivery.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/bgp_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/ping_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/integration_tests/vlan_test.yml'
}
}
stage('Post-Deployment') {
when{
expression {
return env.BRANCH_NAME == "NetLab_master";
}
}
steps {
sh 'ansible-playbook -i hosts Step4-CICD/deployment_tests/port_status_test.yml'
sh 'ansible-playbook -i hosts Step4-CICD/deployment_tests/dynamic_status_test.yml'
}
}
}
}