2020-02-06 09:32:12 +00:00
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
options {
|
|
|
|
// Running builds concurrently could cause a race condition with
|
|
|
|
// building the Docker image.
|
|
|
|
disableConcurrentBuilds()
|
2020-03-17 15:46:53 +00:00
|
|
|
buildDiscarder(logRotator(numToKeepStr: '5'))
|
2020-02-13 07:35:47 +00:00
|
|
|
}
|
2020-02-06 09:32:12 +00:00
|
|
|
stages {
|
|
|
|
// Run the build in the against the dev branch to check for compile errors
|
|
|
|
stage('Run Integration Tests') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
branch 'dev'
|
|
|
|
branch 'master'
|
|
|
|
changeRequest target: 'dev'
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 15:46:53 +00:00
|
|
|
environment {
|
|
|
|
// Some branches have a "/" in their name (e.g. feature/new-and-cool)
|
|
|
|
// Some commands, such as those tha deal with directories, don't
|
|
|
|
// play nice with this naming convention. Define an alias for the
|
|
|
|
// branch name that can be used in these scenarios.
|
|
|
|
BRANCH_ALIAS = sh(
|
|
|
|
script: 'echo $BRANCH_NAME | sed -e "s#/#_#g"',
|
|
|
|
returnStdout: true
|
|
|
|
).trim()
|
|
|
|
}
|
2020-02-06 09:32:12 +00:00
|
|
|
steps {
|
2020-03-17 15:46:53 +00:00
|
|
|
echo 'Building Mark I Voight-Kampff Docker Image'
|
2020-02-06 09:32:12 +00:00
|
|
|
sh 'cp test/Dockerfile.test Dockerfile'
|
2020-03-17 15:46:53 +00:00
|
|
|
sh 'docker build \
|
|
|
|
--target voight_kampff_builder \
|
|
|
|
--build-arg platform=mycroft_mark_1 \
|
|
|
|
-t voight-kampff-mark-1:${BRANCH_ALIAS} .'
|
|
|
|
echo 'Running Mark I Voight-Kampff Test Suite'
|
2020-03-03 09:38:14 +00:00
|
|
|
timeout(time: 60, unit: 'MINUTES')
|
2020-02-06 09:32:12 +00:00
|
|
|
{
|
|
|
|
sh 'docker run \
|
2020-02-20 14:40:23 +00:00
|
|
|
-v "$HOME/voight-kampff/identity:/root/.mycroft/identity" \
|
|
|
|
-v "$HOME/voight-kampff/:/root/allure" \
|
2020-03-17 15:46:53 +00:00
|
|
|
voight-kampff-mark-1:${BRANCH_ALIAS} \
|
2020-02-20 14:40:23 +00:00
|
|
|
-f allure_behave.formatter:AllureFormatter \
|
|
|
|
-o /root/allure/allure-result --tags ~@xfail'
|
2020-02-06 09:32:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-13 10:29:34 +00:00
|
|
|
post {
|
|
|
|
always {
|
|
|
|
echo 'Report Test Results'
|
2020-02-17 09:00:31 +00:00
|
|
|
echo 'Changing ownership...'
|
|
|
|
sh 'docker run \
|
2020-02-20 14:40:23 +00:00
|
|
|
-v "$HOME/voight-kampff/:/root/allure" \
|
2020-02-17 09:00:31 +00:00
|
|
|
--entrypoint=/bin/bash \
|
2020-03-17 15:46:53 +00:00
|
|
|
voight-kampff-mark-1:${BRANCH_ALIAS} \
|
2020-02-17 09:00:31 +00:00
|
|
|
-x -c "chown $(id -u $USER):$(id -g $USER) \
|
2020-02-20 14:40:23 +00:00
|
|
|
-R /root/allure/"'
|
2020-02-17 09:00:31 +00:00
|
|
|
|
2020-03-17 15:46:53 +00:00
|
|
|
echo 'Transferring...'
|
2020-03-03 08:58:28 +00:00
|
|
|
sh 'rm -rf allure-result/*'
|
2020-02-13 19:06:00 +00:00
|
|
|
sh 'mv $HOME/voight-kampff/allure-result allure-result'
|
2020-02-13 10:29:34 +00:00
|
|
|
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 root@157.245.127.234:~;
|
|
|
|
ssh root@157.245.127.234 "unzip -o ~/allure-report.zip";
|
2020-02-13 19:06:00 +00:00
|
|
|
ssh root@157.245.127.234 "rm -rf /var/www/voight-kampff/${BRANCH_ALIAS}";
|
|
|
|
ssh root@157.245.127.234 "mv allure-report /var/www/voight-kampff/${BRANCH_ALIAS}"
|
2020-02-13 10:29:34 +00:00
|
|
|
'''
|
|
|
|
)
|
|
|
|
echo 'Report Published'
|
|
|
|
}
|
|
|
|
}
|
2020-02-06 09:32:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
2020-02-13 10:29:34 +00:00
|
|
|
cleanup {
|
|
|
|
sh(
|
|
|
|
label: 'Docker Container and Image Cleanup',
|
|
|
|
script: '''
|
|
|
|
docker container prune --force;
|
|
|
|
docker image prune --force;
|
|
|
|
'''
|
|
|
|
)
|
2020-02-06 09:32:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|