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 11
/
Copy pathJenkinsfile.yml
77 lines (74 loc) · 3.74 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
// This job will be restricted to run only on 'ubuntu18.04-OnDemand' Build machine
node('ubuntu18.04-OnDemand'){
withEnv([
'REPO_PRI=https://github.com/secure-device-onboard/pri',
'REPO_SCT=https://github.com/secure-device-onboard/supply-chain-tools',
'REPO_IOT=https://github.com/secure-device-onboard/iot-platform-sdk',
'REPO_RV=https://github.com/secure-device-onboard/rendezvous-service',
"TEST_DIR=${WORKSPACE}/sdo-test"
])
{
stage('Clone all-in-one-demo'){
cleanWs()
dir('all-in-one-demo'){
checkout scm
}
sh 'git clone "${REPO_PRI}"'
sh 'git clone "${REPO_SCT}"'
sh 'git clone "${REPO_IOT}"'
sh 'git clone "${REPO_RV}"'
}
stage('Build all-in-one-demo'){
sh 'cd $WORKSPACE/pri; git checkout master; mvn clean install'
sh 'cd $WORKSPACE/iot-platform-sdk; git checkout master; mvn clean install'
sh 'cd $WORKSPACE/supply-chain-tools; git checkout master; mvn clean install'
sh 'cd $WORKSPACE/rendezvous-service; git checkout master; mvn clean install -Dmaven.test.skip=true'
sh 'cd $WORKSPACE/all-in-one-demo; mvn clean install'
print "Archive the artifacts"
archiveArtifacts artifacts: 'all-in-one-demo/demo/aio.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/all-in-one-demo
mkdir -p sdo-test/binaries/client-sdk/x86_ecdsa256_sct_bin
mkdir -p sdo-test/binaries/client-sdk/x86_ecdsa384_sct_bin
'''
print "copying the dependent binaries from pri and client-sdk"
copyArtifacts filter: 'demo.tar.gz', fingerprintArtifacts: true, projectName: 'pri/master', selector: lastSuccessful(), target: 'sdo-test/binaries/pri/'
copyArtifacts excludes: 'SmokeTest_Log.tar.gz', fingerprintArtifacts: true, projectName: 'client-sdk/master', selector: lastSuccessful(), target: 'sdo-test/binaries/'
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
'''
print "Copy client-sdk artifacts to sdo-test/binaries folder"
sh '''
tar -xvzf sdo-test/binaries/client-sdk/x86_ecdsa256_c_sct_bin.tar.gz -C sdo-test/binaries/client-sdk/x86_ecdsa256_sct_bin/ --strip=1
tar -xvzf sdo-test/binaries/client-sdk/x86_ecdsa384_c_sct_bin.tar.gz -C sdo-test/binaries/client-sdk/x86_ecdsa384_sct_bin/ --strip=1
'''
print "Copy aio artifacts to sdo-test/binaries folder"
sh '''
cp -r all-in-one-demo/demo/aio.tar.gz sdo-test/binaries/all-in-one-demo
tar -xvf sdo-test/binaries/all-in-one-demo/aio.tar.gz -C sdo-test/binaries/all-in-one-demo/ --strip=1
'''
print "AIO smoke Tests with client-sdk Device PRI Device"
sh '''
cd sdo-test
mvn clean verify -Dgroups=aio_smoketest
'''
}
} finally {
print "Archive the smoke test logs "
sh 'mkdir SmokeTest_Log'
sh '''
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
}
}