-
Notifications
You must be signed in to change notification settings - Fork 2
/
jenkinsfile_inventory
82 lines (69 loc) · 2.6 KB
/
jenkinsfile_inventory
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
pipeline {
agent
{ docker
{ image 'python:latest' }
}
environment {
JENKINS_REPO_NAME = 'dnacenter_jenkins_automations'
GITHUB_USERNAME = 'gzapodea'
GITHUB_TOKEN = credentials('GITHUB_TOKEN')
}
options {
skipStagesAfterUnstable()
timeout(time: 15, unit: 'MINUTES')
}
stages {
stage ('Build Python Environment') {
steps {
echo '\n\nJenkins Device Inventory build start..............................'
echo('\n\nBuilding the Docker container:..............................')
}
}
stage ('Install Python libraries') {
steps {
echo('\n\nInstalling Python libraries:..............................')
sh 'git clone https://' + GITHUB_USERNAME + ':' + GITHUB_TOKEN + '@github.com/zapodeanu/' + JENKINS_REPO_NAME + '.git'
withEnv(["HOME=${env.WORKSPACE}"]) {
sh 'pip install -r ' + JENKINS_REPO_NAME + '/requirements.txt --no-warn-script-location'
echo('\n\nVerify Python version and Libraries:..............................')
sh 'python --version'
sh 'pip3 list'
echo('\n\nVerify Application Files:..............................')
sh 'ls ' + JENKINS_REPO_NAME + '/'
}
}
}
stage ('Device inventory collection') {
steps {
echo('\n\nCollect the inventory of devices managed by Cisco DNA Center:..............................')
withEnv(["HOME=${env.WORKSPACE}"]) {
echo('\n\nVerify Working Path:..............................')
sh 'pwd'
dir('dnacenter_jenkins_automations') {
sh 'python3 device_inventory.py'
}
}
}
}
stage ('List the "inventory" folder content') {
steps {
echo('\n\nThe inventory files that have been created:..............................')
withEnv(["HOME=${env.WORKSPACE}"]) {
echo('\n\nVerify Working Path:..............................')
sh 'pwd'
dir('dnacenter_jenkins_automations/inventory') {
sh 'ls -l -A'
}
}
}
}
}
post {
cleanup {
cleanWs()
}
always {
echo '\n\nJenkins Device Inventory build end'
}
}
}