This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile.yml
108 lines (105 loc) · 4.96 KB
/
Jenkinsfile.yml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
// This job will be restricted to run only on 'ubuntu18.04-OnDemand' Build machine
node('ubuntu18.04-OnDemand'){
withEnv([
"TEST_DIR=${WORKSPACE}/sdo-test",
"MANUFACTURER_DB_CONNECT_STRING=jdbc:mariadb://127.0.0.1:3306/sdo",
"RESELLER_DB_CONNECT_STRING=jdbc:mariadb://127.0.0.1:4306/sdo"
])
{
// Stage for checking out the sourceCode
stage('scm checkout'){
cleanWs()
checkout scm
}
// Stage to build the project
stage('build'){
sh 'mvn clean package'
print "Archive the artifacts"
sh 'tar -cvzf demo.tar.gz demo'
archiveArtifacts artifacts: 'demo.tar.gz', fingerprint: true, allowEmptyArchive: false
}
try{
stage('Run SmokeTest'){
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'sdo-test']], userRemoteConfigs: [[credentialsId: 'sdo-automationgithubtoken', url: 'https://github.com/secure-device-onboard-ci/sdo-test']]])
sh '''
mkdir -p sdo-test/binaries/pri
mkdir -p sdo-test/binaries/supply-chain-tools
mkdir -p sdo-test/binaries/rendezvous-service
mkdir -p sdo-test/binaries/iot-platform-sdk
'''
print "copying the dependent binaries from pri, supply-chain-tools and rendezvous-service"
copyArtifacts filter: 'demo.tar.gz', fingerprintArtifacts: true, projectName: 'pri/master', selector: lastSuccessful(), target: 'sdo-test/binaries/pri/'
copyArtifacts filter: 'demo.tar.gz', fingerprintArtifacts: true, projectName: 'supply-chain-tools/master', selector: lastSuccessful(), target: 'sdo-test/binaries/supply-chain-tools/'
copyArtifacts filter: 'demo.tar.gz', fingerprintArtifacts: true, projectName: 'rendezvous-service/master', selector: lastSuccessful(), target: 'sdo-test/binaries/rendezvous-service'
print "Extract the dependent binaries to respective folders"
sh '''
tar -xvzf sdo-test/binaries/pri/demo.tar.gz -C sdo-test/binaries/pri/ --strip=1
tar -xvzf sdo-test/binaries/supply-chain-tools/demo.tar.gz -C sdo-test/binaries/supply-chain-tools/ --strip=1
tar -xvzf sdo-test/binaries/rendezvous-service/demo.tar.gz -C sdo-test/binaries/rendezvous-service/ --strip=1
'''
print "Copy IOT artifacts to sdo-test/binaries folder"
sh '''
cp -r demo/* sdo-test/binaries/iot-platform-sdk/
mv sdo-test/binaries/iot-platform-sdk/ocs/ocsfs*.war sdo-test/binaries/iot-platform-sdk/ocs/ocsfs-.war
mv sdo-test/binaries/iot-platform-sdk/ops/ops*.war sdo-test/binaries/iot-platform-sdk/ops/ops-.war
mv sdo-test/binaries/iot-platform-sdk/to0scheduler/to0scheduler-*.war sdo-test/binaries/iot-platform-sdk/to0scheduler/to0scheduler-.war
'''
print "IOT Smoke tests with Pri-Rv&Device"
sh '''
cd sdo-test
mvn clean verify -Dgroups=docker_oc_crirv_smoketest
'''
print "stop containers running rendezvous-service,ocs,ops&to0scheduler"
sh '''
docker system prune -a -f
docker images -a
docker volume ls
docker ps -a
'''
print "Remove and Copy IOT artifacts to sdo-test/binaries folder"
sh '''
rm -rf sdo-test/binaries/iot-platform-sdk/*
cp -r demo/* sdo-test/binaries/iot-platform-sdk/
mv sdo-test/binaries/iot-platform-sdk/ocs/ocsfs*.war sdo-test/binaries/iot-platform-sdk/ocs/ocsfs-.war
mv sdo-test/binaries/iot-platform-sdk/ops/ops*.war sdo-test/binaries/iot-platform-sdk/ops/ops-.war
mv sdo-test/binaries/iot-platform-sdk/to0scheduler/to0scheduler-*.war sdo-test/binaries/iot-platform-sdk/to0scheduler/to0scheduler-.war
'''
print "Create tomcat containers running manufacturer & db"
sh '''
cd sdo-test/binaries/supply-chain-tools/docker_manufacturer/
docker-compose up -d --build
docker logs manufacturer-mariadb
docker logs manufacturer
'''
print "IOT smoke Tests with Pri-Rv&Device, SCT-Manufacturer "
sh '''
cd sdo-test
mkdir voucher
mvn clean verify -Dgroups=docker_oc_sct_crirv_smoketest
'''
}
} finally {
print "stop tomcat containers running manufacturer & db"
sh '''
docker logs manufacturer-mariadb > mariadbLog.txt
docker logs manufacturer > manufacturerLog.txt
docker stop $(docker ps -a -q)
docker rm -v $(docker ps -a -q) -f
docker system prune -a -f
docker images -a
docker volume ls
docker ps -a
'''
print "Archive the smoke test logs "
sh 'mkdir SmokeTest_Log'
sh '''
cp -r *Log.txt SmokeTest_Log/
cp -r sdo-test/logs/*_log.txt SmokeTest_Log/
tar -zcvf SmokeTest_Log.tar.gz SmokeTest_Log
'''
archiveArtifacts artifacts: 'SmokeTest_Log.tar.gz', fingerprint: true, allowEmptyArchive: false
}
//Clean workspace after build is successfull
cleanWs cleanWhenFailure: false, cleanWhenNotBuilt: false, notFailBuild: true
}
}