Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env groovy
- node{
- // vars para deploy, com autenticação do jenkins e hostname do servidor tomcat
- def T_USER= "tomcat"
- def T_PWD = "secret"
- def TOMCAT_HOST = "localhost:8082"
- stage ('Checkout'){
- echo '>> Doing checkout... <<'
- checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '9187dd06-d5f8-4a76-87b2-bec80dd59ade', url: 'https://diogobatista10@bitbucket.org/mei-isep/odsoft-19-20-ncf-g205.git']]])
- }
- ws("${env.WORKSPACE}/odsoft/exercise2/component4/cms") {
- stage ('Build War'){
- echo '>> Building and archiving war file... <<'
- if(isUnix()){
- sh 'gradlew build'
- } else {
- bat 'gradlew build'
- }
- archiveArtifacts artifacts: 'build/libs/*.war'
- }
- stage ('Build Javadoc'){
- echo '>> Building and archiving javadoc... <<'
- if(isUnix()){
- sh 'gradlew javadoc'
- } else {
- bat 'gradlew javadoc'
- }
- archiveArtifacts artifacts: 'build/docs/javadoc/**/*.*'
- }
- stage('Unit Tests') {
- echo '>> Running unit tests and publishing report... <<'
- if(isUnix()){
- sh 'gradlew test jacocoTestReport'
- } else {
- bat 'gradlew test jacocoTestReport'
- }
- archiveArtifacts artifacts: 'build/reports/test/**/*, build/reports/jacoco/test/**/*'
- publishHTML([allowMissing: false,
- alwaysLinkToLastBuild: false,
- keepAll: false,
- reportDir: 'build/reports/test',
- reportFiles: 'index.html',
- reportName: 'Unit Test Report',
- reportTitles: 'Unit Test Report'])
- jacoco execPattern: 'build/jacoco/test.exec'
- }
- stage('Integration Tests') {
- echo '>> Running integration tests and publishing report... <<'
- if(isUnix()){
- sh 'gradlew integrationTest jacocoIntegrationReport'
- } else {
- bat 'gradlew integrationTest jacocoIntegrationReport'
- }
- archiveArtifacts artifacts: 'build/reports/test/**/*, build/reports/jacoco/jacocoIntegrationReport/**/*'
- publishHTML([allowMissing: false,
- alwaysLinkToLastBuild: false,
- keepAll: false,
- reportDir: 'build/reports/integrationTest',
- reportFiles: 'index.html',
- reportName: 'Integration Test Report',
- reportTitles: 'Integration Test Report'])
- jacoco execPattern: 'build/jacoco/integrationTest.exec'
- }
- stage('Mutation Tests') {
- echo '>> Running mutation tests and publishing report... <<'
- if(isUnix()){
- sh 'gradlew pitest'
- } else {
- bat 'gradlew pitest'
- }
- archiveArtifacts artifacts: 'build/reports/pitest/**/*'
- publishHTML([allowMissing: false,
- alwaysLinkToLastBuild: false,
- keepAll: false,
- reportDir: 'build/reports/pitest',
- reportFiles: 'index.html',
- reportName: 'Mutation Test Report',
- reportTitles: 'Mutation Test Report'])
- }
- stage('System Test') {
- echo '>> Deploying application to Tomcat... <<'
- // example syntax curl command: curl -u {username}:{password} -T {filename} {FTP_Location}
- // example syntax deploy: http://localhost:8080/manager/text/deploy?path=/foo
- if(isUnix()){
- sh "curl -u ${T_USER}:${T_PWD} -T build/libs/cms-1.0.war '${TOMCAT_HOST}/manager/text/deploy?path=/cms&update=true'"
- } else {
- bat "curl -u ${T_USER}:${T_PWD} -T build/libs/cms-1.0.war '${TOMCAT_HOST}/manager/text/deploy?path=/cms&update=true'"
- }
- echo '>> Running automatic smoke test <<'
- def smokeTestResult
- // example syntax curl command: curl -sL -w "%{http_code}" "http://www.google.com/" -o /dev/null
- if(isUnix()){
- smokeTestResult = sh "curl -sL -w "%{http_code}" 'http://${TOMCAT_HOST}/cms/' -o /dev/null"
- } else {
- smokeTestResult = bat "curl -sL -w "%{http_code}" 'http://${TOMCAT_HOST}/cms/' -o /dev/null"
- }
- if(smokeTestResult == 200){
- echo '>> Smoke test passed! <<'
- } else {
- echo '>> Smoke test failed. Expected response status code 200 but got ${smokeTestResult} instead'
- }
- }
- stage("UI Acceptance Manual Tests "){
- emailext body: "Build#${BUILD_NUMBER}-${currentBuild.currentResult}\n More info at: ${BUILD_URL}",
- recipientProviders: [[$class: 'RequesterRecipientProvider']],
- subject: "Jenkins Build ${currentBuild.currentResult}"
- input 'Conclude Build?'
- }
- stage("Continuous Integration Feedback "){
- bat("git tag -a Build#${BUILD_NUMBER}-${currentBuild.currentResult} -m 'Jenkins'")
- bat("git push https://diogobatista10@bitbucket.org/mei-isep/odsoft-19-20-ncf-g205.git --tags")
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement