Skip to content
Jenkinsfile 863 B
Newer Older
Luca Verardo's avatar
Luca Verardo committed
pipeline {
    agent {
        docker {
            image 'maven:3-alpine'
        }
    }
Luca Verardo's avatar
Luca Verardo committed
    stages {
        stage('Build') { 
            steps {
                sh 'mvn -B -DskipTests clean package' 
Luca Verardo's avatar
Luca Verardo committed
            }
Zegorax's avatar
Zegorax committed
        }
Luca Verardo's avatar
Luca Verardo committed
        stage('Test') {
Luca Verardo's avatar
Luca Verardo committed
            docker.image('mysql').withRun('-e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=mentorarc -e MYSQL_USER=mentorarc -e MYSQL_PASSWORD=mentorarc') { c ->
                docker.image('maven:3-alpine').inside("--link ${c.id}:db") {
                    /* Wait until mysql service is up */
                    sh 'while ! mysqladmin ping -hdb --silent; do sleep 1; done'

                    sh 'mvn test'
                }
                
Luca Verardo's avatar
Luca Verardo committed
            }
            post {
                always {
                    junit 'target/surefire-reports/*.xml'
                }
            }
        }
Zegorax's avatar
Zegorax committed
    }
Luca Verardo's avatar
Luca Verardo committed
}