Skip to content
Jenkinsfile 4.18 KiB
Newer Older
Luca Verardo's avatar
Luca Verardo committed
pipeline {
Luca Verardo's avatar
Luca Verardo committed
    agent {
        docker {
            image 'docker:dind'
Luca Verardo's avatar
Luca Verardo committed
            args '-v /var/run/docker.sock:/var/run/docker.sock'
Luca Verardo's avatar
Luca Verardo committed
        }
    }
Luca Verardo's avatar
Luca Verardo committed
    stages {
Luca Verardo's avatar
Luca Verardo committed
        // stage('Build') { 
        //     steps {
        //         script {
        //             docker.image('maven:3-alpine').inside { c ->
        //                 checkout scm
        //                 sh 'mv src/main/resources/application.properties.production src/main/resources/application.properties'
        //                 sh 'mvn -B -DskipTests clean package' 
        //             }
        //         }
Luca Verardo's avatar
Luca Verardo committed

                
Luca Verardo's avatar
Luca Verardo committed
        //     }
        // }
        // stage('Test') {
        //     steps{
        //         script {
        //             docker.image('mysql').withRun('-e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=mentorarc -e MYSQL_USER=mentorarc -e MYSQL_PASSWORD=mentorarc') { c ->
        //                 docker.image('mysql').inside("--link ${c.id}:db") {
        //                     /* Wait until mysql service is up */
        //                     sh 'while ! mysqladmin ping -hdb --silent; do sleep 1; done'
        //                 }
Luca Verardo's avatar
Luca Verardo committed

Luca Verardo's avatar
Luca Verardo committed
        //                 docker.image('maven:3-alpine').inside("--link ${c.id}:db") {
        //                     checkout scm
        //                     sh 'mv src/main/resources/application.properties.production src/main/resources/application.properties'
        //                     sh 'mvn test'
        //                 }
        //             }
        //         }
        //     }
Luca Verardo's avatar
Luca Verardo committed
            
Luca Verardo's avatar
Luca Verardo committed
        //     post {
        //         always {
        //             junit 'target/surefire-reports/*.xml'
        //         }
        //     }
        // }
        // stage('Quality'){
        //     steps{
        //         script{
        //             withCredentials([usernamePassword(credentialsId: 'SonarCloud_Zegorax_Token', passwordVariable: 'SONARCLOUD_API_TOKEN', usernameVariable: 'SONARCLOUD_API_USER')]) {
        //                 docker.image('mysql').withRun('-e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=mentorarc -e MYSQL_USER=mentorarc -e MYSQL_PASSWORD=mentorarc') { c ->
        //                     docker.image('mysql').inside("--link ${c.id}:db") {
        //                         /* Wait until mysql service is up */
        //                         sh 'while ! mysqladmin ping -hdb --silent; do sleep 1; done'
        //                     }
        //                     docker.image('maven:3-alpine').inside("--link ${c.id}:db") {
        //                             checkout scm
        //                             sh 'mv src/main/resources/application.properties.production src/main/resources/application.properties'
        //                             sh 'mvn verify sonar:sonar'
        //                     }
        //                 }
        //             }
        //         }
        //     }
        // }
Luca Verardo's avatar
Luca Verardo committed
		stage('IntegrationTests') {
            steps{
                script {
                    docker.image('mysql').withRun('-e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=mentorarc -e MYSQL_USER=mentorarc -e MYSQL_PASSWORD=mentorarc') { c ->
                        docker.image('mysql').inside("--link ${c.id}:db") {
                            /* Wait until mysql service is up */
                            sh 'while ! mysqladmin ping -hdb --silent; do sleep 1; done'
                        }

						docker.image('maven:3-alpine').withRun("--link ${c.id}") { d ->
Luca Verardo's avatar
Luca Verardo committed
							
							checkout scm
							sh 'mv src/main/resources/application.properties.production src/main/resources/application.properties'
							sh 'nohup mvn exec:java &'
Luca Verardo's avatar
Luca Verardo committed

Luca Verardo's avatar
Luca Verardo committed
							docker.image('lucienmoor/katalon-for-jenkins:latest').withRun("--link ${d.id}:mentorarc") {
Luca Verardo's avatar
Luca Verardo committed
								sh 'sleep 20'
								sh 'curl mentorarc:8081'
							}
Luca Verardo's avatar
Luca Verardo committed
						}
                    }
                }
            }
Luca Verardo's avatar
Luca Verardo committed
        // stage ('Performance') {
        // octoPerfTest credentialsId: 'XXXXXX-XXX-XXX-XXXX', scenarioId: 'XXXXXXX'
        // }
Luca Verardo's avatar
Luca Verardo committed
        // stage ('JunitReport') {
        //     junit 'junit-report.xml'
        // }
Luca Verardo's avatar
Luca Verardo committed
        // stage ('PerfReport') {
        //     perfReport modeThroughput: true, sourceDataFiles: '**/*.jtl'
        // }
Zegorax's avatar
Zegorax committed
    }
Luca Verardo's avatar
Luca Verardo committed
}