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-03-30 12:05:32 +00:00
|
|
|
lock resource: 'VoightKampff'
|
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
|
2020-04-15 16:58:32 +00:00
|
|
|
stage('Add CLA label to PR') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
changeRequest target: 'dev'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
environment {
|
|
|
|
//spawns GITHUB_USR and GITHUB_PSW environment variables
|
|
|
|
GITHUB=credentials('38b2e4a6-167a-40b2-be6f-d69be42c8190')
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
// Using an install of Github repo CLA tagger
|
|
|
|
// (https://github.com/forslund/github-repo-cla)
|
|
|
|
sh '~/github-repo-cla/mycroft-core-cla-check.sh'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-06 09:32:12 +00:00
|
|
|
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(
|
2020-04-03 20:59:50 +00:00
|
|
|
script: 'echo $BRANCH_NAME | sed -e "s#/#-#g"',
|
2020-03-17 15:46:53 +00:00
|
|
|
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-04-22 13:39:43 +00:00
|
|
|
sh 'docker build -f test/Dockerfile \
|
2020-03-17 15:46:53 +00:00
|
|
|
--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" \
|
2020-11-13 00:27:42 +00:00
|
|
|
-v "$HOME/allure/core/$BRANCH_ALIAS:/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-11-13 00:27:42 +00:00
|
|
|
-v "$HOME/allure/core/$BRANCH_ALIAS:/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-11-13 00:27:42 +00:00
|
|
|
sh 'mv $HOME/allure/core/$BRANCH_ALIAS/allure-result allure-result'
|
|
|
|
// This directory should now be empty, rmdir will intentionally fail if not.
|
|
|
|
sh 'rmdir $HOME/allure/core/$BRANCH_ALIAS'
|
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-04-03 21:01:53 +00:00
|
|
|
ssh root@157.245.127.234 "rm -rf /var/www/voight-kampff/core/${BRANCH_ALIAS}";
|
|
|
|
ssh root@157.245.127.234 "mv allure-report /var/www/voight-kampff/core/${BRANCH_ALIAS}"
|
2020-02-13 10:29:34 +00:00
|
|
|
'''
|
|
|
|
)
|
|
|
|
echo 'Report Published'
|
|
|
|
}
|
2020-04-03 21:02:18 +00:00
|
|
|
failure {
|
2020-04-08 06:41:57 +00:00
|
|
|
script {
|
|
|
|
// Create comment for Pull Requests
|
|
|
|
if (env.CHANGE_ID) {
|
|
|
|
echo 'Sending PR comment'
|
|
|
|
pullRequest.comment('Voight Kampff Integration Test Failed ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '))')
|
|
|
|
}
|
|
|
|
}
|
2020-04-03 21:02:18 +00:00
|
|
|
// Send failure email containing a link to the Jenkins build
|
|
|
|
// the results report and the console log messages to Mycroft
|
|
|
|
// developers, the developers of the pull request and the
|
|
|
|
// developers that caused the build to fail.
|
|
|
|
echo 'Sending Failure Email'
|
|
|
|
emailext (
|
|
|
|
attachLog: true,
|
|
|
|
subject: "FAILED - Core Integration Tests - Build ${BRANCH_NAME} #${BUILD_NUMBER}",
|
|
|
|
body: """
|
|
|
|
<p>
|
|
|
|
One or more integration tests failed. Use the
|
|
|
|
resources below to identify the issue and fix
|
|
|
|
the failing tests.
|
|
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<p>
|
|
|
|
<a href='${BUILD_URL}'>
|
|
|
|
Jenkins Build Details
|
|
|
|
</a>
|
|
|
|
 (Requires account on Mycroft's Jenkins instance)
|
|
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<p>
|
|
|
|
<a href='https://reports.mycroft.ai/core/${BRANCH_ALIAS}'>
|
|
|
|
Report of Test Results
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<p>Console log is attached.</p>""",
|
|
|
|
replyTo: 'devops@mycroft.ai',
|
|
|
|
to: 'dev@mycroft.ai',
|
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'RequesterRecipientProvider'],
|
|
|
|
[$class:'CulpritsRecipientProvider'],
|
|
|
|
[$class:'DevelopersRecipientProvider']
|
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
success {
|
2020-04-08 06:41:57 +00:00
|
|
|
script {
|
|
|
|
if (env.CHANGE_ID) {
|
|
|
|
echo 'Sending PR comment'
|
|
|
|
pullRequest.comment('Voight Kampff Integration Test Succeeded ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '))')
|
|
|
|
}
|
|
|
|
}
|
2020-04-03 21:02:18 +00:00
|
|
|
// Send success email containing a link to the Jenkins build
|
|
|
|
// and the results report to Mycroft developers, the developers
|
|
|
|
// of the pull request and the developers that caused the
|
|
|
|
// last failed build.
|
|
|
|
echo 'Sending Success Email'
|
|
|
|
emailext (
|
|
|
|
subject: "SUCCESS - Core Integration Tests - Build ${BRANCH_NAME} #${BUILD_NUMBER}",
|
|
|
|
body: """
|
|
|
|
<p>
|
|
|
|
All integration tests passed. No further action required.
|
|
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<p>
|
|
|
|
<a href='${BUILD_URL}'>
|
|
|
|
Jenkins Build Details
|
|
|
|
</a>
|
|
|
|
 (Requires account on Mycroft's Jenkins instance)
|
|
|
|
</p>
|
|
|
|
<br>
|
|
|
|
<p>
|
|
|
|
<a href='https://reports.mycroft.ai/core/${BRANCH_ALIAS}'>
|
|
|
|
Report of Test Results
|
|
|
|
</a>
|
|
|
|
</p>""",
|
|
|
|
replyTo: 'devops@mycroft.ai',
|
|
|
|
to: 'dev@mycroft.ai',
|
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'RequesterRecipientProvider'],
|
|
|
|
[$class:'CulpritsRecipientProvider'],
|
|
|
|
[$class:'DevelopersRecipientProvider']
|
|
|
|
]
|
|
|
|
)
|
|
|
|
}
|
2020-02-13 10:29:34 +00:00
|
|
|
}
|
2020-02-06 09:32:12 +00:00
|
|
|
}
|
2020-05-20 06:28:00 +00:00
|
|
|
// Build snap package for release
|
|
|
|
stage('Build development Snap package') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
branch 'dev'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo "Launching package build for ${env.BRANCH_NAME}"
|
|
|
|
build (job: '../Mycroft-snap/dev', wait: false,
|
|
|
|
parameters: [[$class: 'StringParameterValue',
|
|
|
|
name: 'BRANCH', value: env.BRANCH_NAME]])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build Release Snap package') {
|
|
|
|
when {
|
|
|
|
tag "release/v*.*.*"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo "Launching package build for ${env.TAG_NAME}"
|
|
|
|
build (job: '../Mycroft-snap/dev', wait: false,
|
|
|
|
parameters: [[$class: 'StringParameterValue',
|
|
|
|
name: 'BRANCH', value: env.TAG_NAME]])
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 19:45:23 +00:00
|
|
|
// Build a voight_kampff image for major releases. This will be used
|
|
|
|
// by the mycroft-skills repository to test skill changes. Skills are
|
|
|
|
// tested against major releases to determine if they play nicely with
|
|
|
|
// the breaking changes included in said release.
|
|
|
|
stage('Build Major Release Image') {
|
|
|
|
when {
|
|
|
|
tag "release/v*.*.0"
|
|
|
|
}
|
|
|
|
environment {
|
|
|
|
// Tag name is usually formatted like "20.2.0" whereas skill
|
|
|
|
// branch names are usually "20.02". Reformat the tag name
|
|
|
|
// to the skill branch format so this image will be easy to find
|
|
|
|
// in the mycroft-skill repository.
|
|
|
|
SKILL_BRANCH = sh(
|
|
|
|
script: 'echo $TAG_NAME | sed -e "s/v//g" -e "s/[.]0//g" -e "s/[.]/.0/g"',
|
|
|
|
returnStdout: true
|
|
|
|
).trim()
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'Building ${TAG_NAME} Docker Image for Skill Testing'
|
2020-04-22 13:39:43 +00:00
|
|
|
sh 'docker build -f test/Dockerfile \
|
2020-03-17 19:45:23 +00:00
|
|
|
--target voight_kampff_builder \
|
|
|
|
--build-arg platform=mycroft_mark_1 \
|
|
|
|
-t voight-kampff-mark-1:${SKILL_BRANCH} .'
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|