diff --git a/Jenkinsfile b/Jenkinsfile index 3637de6..5c9be77 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,93 +4,71 @@ pipeline { stage('checkout project') { steps { checkout scm + sh 'docker run -v `pwd`:/app -v $HOME/.m2:/root/.m2 -w /app localhost:5000/maven mvn cobertura:cobertura test' } } - stage('check env') { + stage('Report') { parallel { - stage('check mvn') { + stage('Report') { steps { - sh 'mvn -v' + junit 'target/surefire-reports/*.xml' } } - stage('check java') { + stage('Report2') { steps { - sh 'java -version' + cobertura(coberturaReportFile: 'target/site/cobertura/coverage.xml') } } } } - - stage('test') { + stage('Package') { steps { - sh 'mvn test cobertura:cobertura' - } - } - stage('report') { - parallel { - stage('junit') { - steps { - junit '**/target/surefire-reports/TEST-*.xml' - } - } - stage('coverage') { - steps { - cobertura(coberturaReportFile: 'target/site/cobertura/coverage.xml') - } - } + sh 'docker run -v `pwd`:/app -v $HOME/.m2:/root/.m2 -w /app -p 8800:8000 localhost:5000/maven mvn package' } } - stage('package') { + stage('Artiche') { steps { - sh 'mvn package' + archiveArtifacts 'target/*.jar' } } - stage('stage') { - input { - message "Should we continue?" - ok "Yes, we should." - submitter "admin" - parameters { - string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') - } - } - steps { - echo "Hello, ${PERSON}, nice to meet you." - sh 'make deploy-default' - } - } - stage('preview') { - input { - message "Should we continue?" - ok "Yes, we should." - submitter "admin" - } - steps { - echo "every thing is good!" + stage('wait for confirm') { + input { + message 'Should we deploy?' + id 'Yes, we should.' + submitter 'admin' + parameters { + string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?') } - } - stage('artifact') { + } steps { - archiveArtifacts(artifacts: '**/target/*.jar', fingerprint: true) + echo "Hello, ${PERSON}, nice to meet you." } } - stage('deploy') { + stage('Deploy') { steps { - sh 'make deploy-default' + sh '''docker build -t localhost:5000/spring-boot-sample-prod ./ +docker push localhost:5000/spring-boot-sample-prod +docker pull localhost:5000/spring-boot-sample-prod +docker run -d -p 8800:8000 localhost:5000/spring-boot-sample-prod +''' } } } - post { - always { + post { + always { echo 'I will always say Hello again!' + } - success { + + success { echo 'success!' - // slackSend channel: '#integration', color: 'good', message: "success ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' - } - failure { + + } + + failure { echo 'failure!' - // slackSend channel: '#integration', color: 'danger', message: "fail ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)", teamDomain: 'agileworks-tw', token: 'JhXFKEl6cBFoQ4v52BEJw9Mr' + } - } + + } } \ No newline at end of file