I have a Jenkins-Pipeline that successfully builds a docker-image. But when it comes to running the docker-image it fails. Inside the docker image I have some API-tests that I want to run with ctest. The tests can be executed by calling test in the directory /testing.
Any suggestions?
pipeline {
agent {label 'apitest-centos7'}
stages {
stage('cleanup'){
steps{
cleanWs()
}
}
stage('git checkout Dockerfile') {
steps{
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'ebf01b-3gf93-4f8e-9f69-97ffgff308af', url: 'http://gitlab.somecompany.loc/somecompany/MyApiTestingTools.git']]])
sh 'ls'
}
}
stage('build Dockerimage'){
steps{
dir('dockerbuild'){
fileExists 'Dockerfile'
sh 'sudo docker build --no-cache=true -t apitestimage .'
}
}
}
stage('start Dockerimage and Tests') {
steps{
dir("dockerbuild"){
withDockerContainer(args: "-ti apitestimage bash -c 'cd testing && ctest", image: 'apitestimage') {
}
}
}
}
}
post {
always {
/*mattermostSend color: 'good', message: 'API-Tests have been executed'*/
deleteDir() /* clean up our workspace */
}
success {
mattermostSend color: 'good', message: 'API-Tests succeded', channel: 'api-tests'
}
unstable {
mattermostSend color: 'warning', message: 'API-Tests are unstable', channel: 'api-tests'
}
failure {
mattermostSend color: 'danger', message: 'API-Tests have failed', channel: 'api-tests', icon: 'https://talks.bitexpert.de/zendcon16-jenkins-for-php-projects/images/jenkins.png'
}
changed {
mattermostSend color: 'warning', message: 'API-Tests have changed', channel: 'api-tests'
}
}
}