forked from CiscoDevNet/ps-crn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
96 lines (95 loc) · 4.17 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
pipeline {
agent {
dockerfile {
filename 'Dockerfile'
args '-v /etc/passwd:/etc/passwd'
}
}
options {
disableConcurrentBuilds()
lock resource: 'jenkins_ps-crn_master'
}
environment {
VIRL_USERNAME = credentials('cpn-virl-username')
VIRL_PASSWORD = credentials('cpn-virl-password')
VIRL_HOST = credentials('cpn-virl-host')
VIRL_SESSION = "jenkins_ps-crn_master"
VIPTELA_ORG = credentials('viptela-org')
LICENSE_TOKEN = credentials('license-token')
HOME = "${WORKSPACE}"
DEFAULT_LOCAL_TMP = "${WORKSPACE}/ansible"
}
stages {
stage('Clean Previous Deployment') {
steps {
echo 'Running build.yml...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'clean.yml'
cleanWs()
}
}
stage('Prep New Environment') {
steps {
// GIT submodule recursive checkout
checkout scm: [
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: false,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false]],
submoduleCfg: [],
userRemoteConfigs: scm.userRemoteConfigs
]
echo 'Running build.yml...'
sh 'cp ansible.cfg.docker ansible.cfg'
}
}
stage('Build VIRL Topology') {
steps {
echo 'Running build.yml...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'build.yml'
echo 'Configure licensing...'
ansiblePlaybook disableHostKeyChecking: true, extras: "-e license_token=${LICENSE_TOKEN}", playbook: 'configure-licensing.yml'
}
}
stage('Configure SD-WAN Fabric') {
steps {
echo 'Configure Viptela Control Plane...'
withCredentials([file(credentialsId: 'viptela-serial-file', variable: 'VIPTELA_SERIAL_FILE')]) {
ansiblePlaybook disableHostKeyChecking: true, extras: '-e virl_tag=jenkins -e \'organization_name="${VIPTELA_ORG}"\' -e serial_number_file=${VIPTELA_SERIAL_FILE} -e viptela_cert_dir=${WORKSPACE}/myCA', tags: 'control', playbook: 'configure.yml'
}
echo 'Configure Viptela Edge...'
withCredentials([file(credentialsId: 'viptela-serial-file', variable: 'VIPTELA_SERIAL_FILE')]) {
ansiblePlaybook disableHostKeyChecking: true, extras: '-e virl_tag=jenkins -e \'organization_name="${VIPTELA_ORG}"\' -e serial_number_file=${VIPTELA_SERIAL_FILE} -e viptela_cert_dir=${WORKSPACE}/myCA', tags: 'edge', playbook: 'configure.yml'
}
echo 'Loading Templates...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'import-templates.yml'
echo 'Waiting for vEdges to Sync...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'waitfor-sync.yml'
echo 'Attaching Templates...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'attach-template.yml'
echo 'Loading Policy...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'import-policy.yml'
echo 'Activating Policy...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'activate-policy.yml'
}
}
stage('Running Tests') {
steps {
echo 'Check SD-WAN...'
ansiblePlaybook disableHostKeyChecking: true, playbook: 'check-sdwan.yml'
}
}
}
/*
post {
always {
ansiblePlaybook disableHostKeyChecking: true, playbook: 'clean.yml'
cleanWs()
}
}
*/
}