forked from MycroftAI/mycroft-skills
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
79 lines (79 loc) · 3.06 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
pipeline {
agent any
options {
// Running builds concurrently could cause a race condition with
// building the Docker image.
disableConcurrentBuilds()
// Only keep the last 5 builds.
buildDiscarder(logRotator(numToKeepStr: '5'))
}
stages {
stage('Run Integration Tests') {
when {
anyOf {
changeRequest()
}
}
environment {
//spawns GITHUB_USR and GITHUB_PSW environment variables
GITHUB=credentials('c5770310-9e46-4ab1-84d4-bb17ae2b2bfb')
}
steps {
sh 'docker build \
--build-arg major_release=20.02 \
--build-arg platform=mycroft_mark_1 \
--build-arg pull_request=$BRANCH_NAME \
--build-arg branch_name=$CHANGE_BRANCH \
--build-arg github_api_key=$GITHUB_PSW \
--no-cache \
-t voight-kampff-skill:$BRANCH_NAME .'
echo 'Running Tests'
timeout(time: 60, unit: 'MINUTES')
{
sh 'docker run \
--volume "$HOME/voight-kampff/identity:/root/.mycroft/identity" \
--volume "$HOME/voight-kampff/:/root/allure" \
voight-kampff-skill:$BRANCH_NAME \
-f allure_behave.formatter:AllureFormatter \
-o /root/allure/allure-result --tags ~@xfail'
}
}
post {
always {
echo 'Report Test Results'
sh 'mv $HOME/voight-kampff/allure-result allure-result'
script {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'allure-result']]
])
}
unarchive mapping:['allure-report.zip': 'allure-report.zip']
sh (
label: 'Publish Report to Web Server',
script: '''scp allure-report.zip [email protected]:~;
ssh [email protected] "unzip -o ~/allure-report.zip";
ssh [email protected] "rm -rf /var/www/voight-kampff/skills/${BRANCH_NAME}";
ssh [email protected] "mv allure-report /var/www/voight-kampff/skills/${BRANCH_NAME}"
'''
)
echo 'Report Published'
}
}
}
}
post {
cleanup {
sh(
label: 'Docker Container and Image Cleanup',
script: '''
docker container prune --force;
docker image prune --force;
'''
)
}
}
}