diff --git a/Jenkins_Tweak b/Jenkins_Tweak new file mode 100644 index 0000000..619e108 --- /dev/null +++ b/Jenkins_Tweak @@ -0,0 +1,93 @@ +pipeline { + + //agent any 2 + agent { + kubernetes { + label 'SpringBootRestApp' + defaultContainer 'jnlp' + yaml """ +apiVersion: v1 +kind: Pod +metadata: +labels: + component: ci +spec: + containers: + - name: gradle + image: gradle:3.5-jdk8-alpine + command: + - cat + tty: true +""" +} + } + + stages { + + stage('SCM Checkout') { + steps { + + + + /* //git branch: 'feature', credentialsId: 'git_creds', url: 'https://github.com/sdgcpsb/SpringBootRestApp.git' + + script { + propfile = readProperties(file: './project.properties') + println ("reading properties ...") +println ("branch_name:"+ propfile['deploy']) + + } */ + + } + + + + } + + + + stage ("Deploy") { + steps { + container ('gradle') { + sh ''' + + deploy=`cat project.properties | grep "feature_deploy" | cut -d'=' -f2 | awk '{print $1}' ` + + + if test "$deploy" = true + then + echo " im deploying" + else + echo "no need" + fi + + server_list=`cat project.properties | grep "servers" | cut -d'=' -f2 ` + echo $server_list + for server in $server_list + + do + + echo $server + done + + + + ''' + + + + } + } + } + stage ("use env vars") { + steps { + sh "printenv | sort" + echo "BUILD_NUMBER = ${env.BUILD_NUMBER}" + echo "BRANCH_NAME = ${env.BRANCH_NAME}" + } + } + + + } +} + diff --git a/Jenkinsfile_AIP b/Jenkinsfile_AIP index aec1851..c00ca43 100644 --- a/Jenkinsfile_AIP +++ b/Jenkinsfile_AIP @@ -1,10 +1,11 @@ +def propfile + pipeline { - - agent { - kubernetes { - label 'SpringBootRestApp' - defaultContainer 'jnlp' - yaml """ + agent { + kubernetes { + label 'SpringBootRestApp' + defaultContainer 'jnlp' + yaml """ apiVersion: v1 kind: Pod metadata: @@ -18,166 +19,231 @@ spec: - cat tty: true """ -} - } - -stages { - stage('Build & Unit Test') { - steps { - container('gradle') { - withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName: 'Sonarqube') { - echo 'I am executing unit test' - // sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do gradle --no-daemon -p ${i} clean build;done' - sh 'mvn -f sample-java-app/pom.xml clean package' - sh 'mvn -X javadoc:javadoc -o' + } + } + environment { + GRADLE_PATH = '/opt/gradle/gradle-3.5.1/bin' + GRADLE_TASK = 'EcomEJBProxy' + DEPLOYMENT_ARCHIVE_DIR='/home/muleadmin/stage/archive' + DEPLOYMENT_STAGE_DIR='/home/muleadmin/stage' + DEPLOYMENT_DIR='/var/WebSphere/deploy' + WAR_FILES='EcomEJBProxy' + ESB_BIN_PATH='/opt/mule/bin/esb_service' + ESB_WAR_FOLDERS='PaymentESB ESBAuditLog OrderReconESB FraudESB TaxESB FulfillmentESB AlertESB ESBAutomatedQueueRetry' + REQUESTID='779' + STAGE_NAME='dev3' + WORKSOFT_URI='http://pwwsftapp01/executionmanager/api' + USERNAME='devopsengineering@signetjewelers.com' + USERNAME_FEATURE_DEPLOY='wasadmin' + HOSTS_FEATURE_DEPLOY="10.6.74.90" + USERNAME_DEV_DEPLOY='wasadmin' + HOSTS_DEV_DEPLOY="10.6.74.91, 10.6.74.92" + USERNAME_RELEASE='wasadmin' + HOSTS_RELEASE_DEPLOY="10.6.74.93, 10.6.74.94" + ARTIFACT="EJB-branch-${env.GIT_BRANCH}-build-${env.BUILD_NUMBER}" + } + stages { + stage('Build & Unit Test') { + steps { + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { + echo 'I am executing build and unit test' + echo 'use the command below when we switch to EJB source' + //sh 'gradle --no-daemon clean build' + echo 'Add gradle clean and build for EJB and comment this step' + sh "mvn -Drevision=${ARTIFACT} -f sample-java-app/pom.xml clean package" + propfile = readProperties(file: './project.properties') + if (propfile['javadoc'] == "true") { + sh 'mvn javadoc:aggregate' + } + if (propfile['jacoco'] == "true") { + jacoco( + execPattern: '**/*.exec', + classPattern: '**/*.class', + sourcePattern: '**/*.java', + exclusionPattern: '**/test*' + ) + } + } } } } } - } - stage('Code Quality') { - steps { - container('gradle') { - withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName: 'Sonarqube') { - echo 'I am executing code quality using sonarqube' - sh 'mvn -f sample-java-app/pom.xml sonar:sonar' + stage('Code Quality') { + when { expression {propfile['code_quality'] == "true" }} + steps { + container('gradle') { + withMaven(maven: 'MAVEN-3.6.3') { + withSonarQubeEnv(installationName: 'Sonarqube') { + echo 'I am executing code quality using sonarqube' + echo "Change the line below when we switch to the actual EJB repo" + // sh 'gradle SonarQube' + echo 'Remove the line below when we switch to the actual EJB repo' + sh "mvn -f sample-java-app/pom.xml -Dsonar.projectName=EJB_${env.GIT_BRANCH} -Dsonar.projectKey=EJB_sample sonar:sonar" + } + sleep(60) + timeout(time: 1, unit: 'MINUTES') { + waitForQualityGate abortPipeline: true + } } - sleep(60) - timeout(time: 1, unit: 'MINUTES') { - waitForQualityGate abortPipeline: true - } } } } - } - stage("Publish Package") { - steps { - container('gradle') { - script { - propfile = readProperties(file: './project.properties') - println("deploy:" + propfile['feature_deploy']) - println("reading properties ...") - if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { + stage("Publish Package") { + when { expression {env.GIT_BRANCH == 'dev' || env.GIT_BRANCH == 'release'|| propfile['feature_deploy'] == "true" }} + steps { + container('gradle') { + script { withMaven(maven: 'MAVEN-3.6.3') { echo 'I am pushing the artifact with unique name showing the branch from which it is generated, to Archiva' - /* echo 'copying the jar and war files from the individual target directorrys and copying it to artifacts directory ' + echo 'Replace the next 4 lines to reflect the EJB artifact and push it to archiva' + echo 'Use the 5 lines below when we switch to the actual EJB repo' + /* echo 'copying the jar and war files from the individual target directories and copying it to artifacts directory ' sh "mkdir -p $WORKSPACE/artifacts" - sh 'for i in ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB;do cp -rp ${i}/dist/libs/* $WORKSPACE/artifacts/ ;done' */ - /* echo 'create a tar file on the Jenkins server' - sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true */ - sh 'mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar' + sh "cp /dist/libs/* $WORKSPACE/artifacts/" + echo 'create a tar file on the Jenkins server' + sh "cd $WORKSPACE/artifacts/ && tar -cvzf artifact.tar * && md5sum artifact.tar archiveArtifacts artifacts: 'artifacts/*.tar', fingerprint: true + */ + echo 'Remove the 3 lines below when we switch to the actual EJB repo' + // sh "mv sample-java-app/target/sample-0.0.1-SNAPSHOT.jar sample-java-app/target/EJB_build-${BUILD_NUMBER}_branch-${env.GIT_BRANCH}.jar" sh 'ls -lrt sample-java-app/target/' - sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-build_${BUILD_NUMBER}-branch_${BRANCH_NAME}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/' - echo "noooooooooooooooooo" + sh "mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-${ARTIFACT}.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/" } } } } } - } - stage("Deploy") { - steps { - container('gradle') { - script { - propfile = readProperties(file: './project.properties') - println("deploy:" + propfile['feature_deploy']) - println("reading properties ...") - if (propfile['feature_deploy'] == "true" || env.BRANCH_NAME == 'dev' || env.BRANCH_NAME == 'release') { + stage("Deploy") { + when { expression {env.GIT_BRANCH == 'dev' || env.GIT_BRANCH == 'release'|| propfile['feature_deploy'] == "true" }} + steps { + container('gradle') { + script { withMaven(maven: 'MAVEN-3.6.3') { - echo 'I am deploying the artifact into the target environment' - echo 'shutting down the tomcat ESB server' - /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH stop || sleep 20"' - echo 'force stop any remaining mule process' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "if [[ $(ps aux | grep /opt/mule/latest/ | grep -vc grep) > 0 ]]; then "kill -9 $(ps -ef|pgrep -f "/opt/mule/latest/bin")"; else echo "do nothing"; fi"' */ - echo 'tomcat server stopped' - echo 'copying the tar file from jenkins to deployment directory on app and remove the old folders and untarring the new jar and war files' - /* sh 'scp -rp $WORKSPACE/artifacts/artifact.tar $DEPLOYMENT_USER@$DEPOYMENT_SERVER:$DEPLOYMENT_STAGE_DIR/' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && rm -rf *.war *.jar"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_STAGE_DIR && tar -xvzf artifact.tar && rm -rf *.jar"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "cd $DEPLOYMENT_DIR && rm -rf $ESB_WAR_FOLDERS && cp -rp $DEPLOYMENT_STAGE_DIR/*.war $DEPLOYMENT_DIR"' */ - echo 'Deployment has been completed' - echo 'starting the tomcat ESB server' - /* sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "$ESB_BIN_PATH start"' - sh 'ssh $DEPLOYMENT_USER@$DEPOYMENT_SERVER "sleep 20"' */ - echo 'tomcat server started' - } - } else { - echo "no need" + if (propfile['feature_deploy'] == "true" ) { + USERNAME=env.USERNAME_FEATURE_DEPLOY + HOSTS=env.HOSTS_FEATURE_DEPLOY + } + if (env.GIT_BRANCH == 'dev' ) { + USERNAME=env.USERNAME_DEV_DEPLOY + HOSTS=env.HOSTS_DEV_DEPLOY + } + if (env.GIT_BRANCH == 'release') { + USERNAME=env.USERNAME_RELEASE_DEPLOY + HOSTS=env.HOSTS_RELEASE_DEPLOY + } + HOSTS.tokenize(',').each { HOSTNAME -> + echo 'I am deploying the artifact into the target environment ${HOSTNAME} as user ${USERNAME}' + echo 'Replace all the lines below for EJB and add the parameters to propfile and make refrences below' + echo 'Accom logic for multiple env and mult servers in each env based on the branch name' + echo 'shutting down the tomcat ESB server' + /* sh 'ssh ${USERNAME}@${HOSTNAME} "$ESB_BIN_PATH stop || sleep 20"' + echo 'force stop any remaining mule process' + sh 'ssh ${USERNAME}@${HOSTNAME} "if [[ $(ps aux | grep /opt/mule/latest/ | grep -vc grep) > 0 ]]; then "kill -9 $(ps -ef|pgrep -f "/opt/mule/latest/bin")"; else echo "do nothing"; fi"' + */ + echo 'tomcat server stopped' + echo 'copying the tar file from jenkins to deployment directory on app and remove the old folders and untarring the new jar and war files' + /* sh 'scp -rp $WORKSPACE/artifacts/artifact.tar $DEPLOYMENT_USER@$DEPOYMENT_SERVER:$DEPLOYMENT_STAGE_DIR/' + sh 'ssh ${USERNAME}@${HOSTNAME} "cd $DEPLOYMENT_STAGE_DIR && rm -rf *.war *.jar"' + sh 'ssh ${USERNAME}@${HOSTNAME} "cd $DEPLOYMENT_STAGE_DIR && tar -xvzf artifact.tar && rm -rf *.jar"' + sh 'ssh ${USERNAME}@${HOSTNAME} "cd $}DEPLOYMENT_DIR} && rm -rf ${ESB_WAR_FOLDERS} && cp -rp ${DEPLOYMENT_STAGE_DIR}/*.war $DEPLOYMENT_DIR"' + */ + echo 'Deployment has been completed' + echo 'starting the tomcat ESB server' + /* sh 'ssh ${USERNAME}@${HOSTNAME} "${ESB_BIN_PATH start}"' + sh 'ssh ${USERNAME}@${HOSTNAME} "sleep 20"' + */ + echo 'tomcat server started' + } + } } } } } -} - - stage('Post Deploy Tests') { - parallel { - stage('Smoke Test') { - steps { - echo "I am executing Smoke Test on target dev environment post deployment" + stage('Post Deploy Tests') { + when { expression {env.GIT_BRANCH == 'dev' || env.GIT_BRANCH == 'release'|| propfile['feature_deploy'] == "true" }} + parallel { + stage('Smoke Test') { + steps { + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { + echo "I am executing Smoke Test on target dev environment post deployment" + /*RESP=`curl -X GET "${bamboo.uri}/RequestsRunning" -H "accept: application/xml" -H "authorization: bearer lR0AA2qfq7v9Ry96vDAgqcer1GPVd5yStmv1_aJVFS43rk06EytB7WsS0_owoiXIgpOXmZVEfkY4ST0JwHtRBk7RH0QRaldWtQT8udC0VdimdGx38RddY2sGaeeF0t9Aflr5rh1Jc_EUfkNK8YrKVxQ6kxB05aCe46CD2fkognv7TiJATmht-ycUjEsd_oy8jH5EK9fmn9eL-wXavNTQcEdsUmFm3-2r3IJDzMK7XCa74qu353yOKLvVyZ1yYQBnc1_fY5GS1BDrFLUZprxpAS30lGEu-d_JTTOQ989UJtIEB3cZzDkIQzeqdYBGCsiDdjdHo2DC1FK2kVPyBITTbQ"` + echo "The response for current execution status is: $RESP" + if [ "$RESP" != "[]" ]; + then + echo "There is a test executing currently in Worksoft. Hence, not proceeding with the execution of Worksoft test cases." + exit 1 + else + echo "There are no tests executing right now. Hence, proceeding with Worksoft test execution" + fi + # To abort the request before attempting to re-run, uncomment and run below line. + # abort=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/Request/${bamboo.RequestID}/abort/) + guid=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "parameters: {TestEnv}{${bamboo.stage_name}}" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/ExecuteRequest/ | tr -d \") + echo "The GUID is: $guid" + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) + echo "The status is: $status" + while [[ $status != *"Completed"* ]] + do + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) + echo "The status is: $status" + sleep 15 + done + status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/) + echo "The status is: $status" + execstatus=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $3}' | tr -d \" | tr -d \}) + echo "The exec status is: $execstatus" + if [[ $execstatus != *Passed* ]]; + then + echo "Failed" + exit 1 + else + echo "Passed" + exit + fi + exit */ + } + } + } + } } - /*RESP=`curl -X GET "${bamboo.uri}/RequestsRunning" -H "accept: application/xml" -H "authorization: bearer lR0AA2qfq7v9Ry96vDAgqcer1GPVd5yStmv1_aJVFS43rk06EytB7WsS0_owoiXIgpOXmZVEfkY4ST0JwHtRBk7RH0QRaldWtQT8udC0VdimdGx38RddY2sGaeeF0t9Aflr5rh1Jc_EUfkNK8YrKVxQ6kxB05aCe46CD2fkognv7TiJATmht-ycUjEsd_oy8jH5EK9fmn9eL-wXavNTQcEdsUmFm3-2r3IJDzMK7XCa74qu353yOKLvVyZ1yYQBnc1_fY5GS1BDrFLUZprxpAS30lGEu-d_JTTOQ989UJtIEB3cZzDkIQzeqdYBGCsiDdjdHo2DC1FK2kVPyBITTbQ"` - echo "The response for current execution status is: $RESP" - if [ "$RESP" != "[]" ]; - then - echo "There is a test executing currently in Worksoft. Hence, not proceeding with the execution of Worksoft test cases." - exit 1 - else - echo "There are no tests executing right now. Hence, proceeding with Worksoft test execution" - fi - # To abort the request before attempting to re-run, uncomment and run below line. - # abort=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/Request/${bamboo.RequestID}/abort/) - guid=$(curl -X PUT -H "Authorization: Bearer $token" -d "" -H "parameters: {TestEnv}{${bamboo.stage_name}}" -H "id: ${bamboo.RequestID}" ${bamboo.uri}/ExecuteRequest/ | tr -d \") - echo "The GUID is: $guid" - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) - echo "The status is: $status" - while [[ $status != *"Completed"* ]] - do - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $2}' | tr -d \" | tr -d \}) - echo "The status is: $status" - sleep 15 - done - status=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/) - echo "The status is: $status" - execstatus=$(curl -X GET -H "Authorization: Bearer $token" -d "" -H "APIRequestID: $guid" ${bamboo.uri}/ExecutionStatus/ | awk -F':' '{print $3}' | tr -d \" | tr -d \}) - echo "The exec status is: $execstatus" - if [[ $execstatus != *Passed* ]]; - then - echo "Failed" - exit 1 - else - echo "Passed" - exit - fi - exit */ - } - stage('Security Test') { - steps { - echo 'I am running Security Test here' + stage('Security Test') { + steps { + container('gradle') { + script { + withMaven(maven: 'MAVEN-3.6.3') { + echo 'I am running Security Test here' + } + } + } + } } } - } - } - } - post { - failure { - /*mail bcc: '', - body: "Example
\n
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", - cc: '', - charset: 'UTF-8', - from: '', - mimeType: 'text/html', - replyTo: '', - subject: "ERROR CI: Project name -> ${env.JOB_NAME}", - to: "foo@foomail.com";*/ - echo 'I am sending a notification with failure' - } - success { - echo 'I am sending a notification with success' + } } - always { - javadoc: Publish Javadoc - } - } + post { + always { + script { + if (propfile['javadoc'] == "true") { + javadoc(javadocDir: "/$WORKSPACE/target/site/apidocs", keepAll: true) + } + } + } + failure { + /*mail bcc: '', + body: "Example
\n
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
URL de build: ${env.BUILD_URL}", + cc: '', + charset: 'UTF-8', + from: '', + mimeType: 'text/html', + replyTo: '', + subject: "ERROR CI: Project name -> ${env.JOB_NAME}", + to: "foo@foomail.com";*/ + echo 'I am sending a notification with failure' + } + success { + echo 'I am sending a notification with success' + } + } } diff --git a/Jenkinsfile_DNU b/Jenkinsfile_DNU index cb3d5d4..53db3d5 100644 --- a/Jenkinsfile_DNU +++ b/Jenkinsfile_DNU @@ -1,70 +1,67 @@ pipeline { - environment { + environment { PROJECT_ID = "sd-devops" APP_NAME = "sample-java-app" CLUSTER_NAME = "cluster-1" CLUSTER_ZONE = "us-central1-a" CREDENTIALS_ID = "sd-devops" - } + } //agent any 2 - agent { - kubernetes { - label 'SpringBootRestApp' - defaultContainer 'jnlp' - yaml """ -apiVersion: v1 -kind: Pod -metadata: -labels: - component: ci -spec: - containers: - - name: gradle - image: gradle:3.5-jdk8-alpine - command: - - cat - tty: true -""" -} + agent { + kubernetes { + label 'SpringBootRestApp' + defaultContainer 'jnlp' + yaml """ + apiVersion: v1 + kind: Pod + metadata: + labels: + component: ci + spec: + containers: + -name: gradle + image: gradle: 3.5 - jdk8 - alpine + command: + -cat + tty: true + """ + } } - - stages { - stage('check_gradle_version') { - steps { - container('gradle') { - sh 'gradle -v' - sh 'echo workspace is $WORKSPACE' - sh "ls -la ${pwd()}" - sh 'chmod 777 * ' - sh './gradlew compileJava' - } - } - } - - - stage('Unit Test') { - steps { - container('gradle') { - withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName:'Sonarqube') { - echo 'I am executing unit test' - sh "ls -la ${pwd()}" - sh 'mvn -f sample-java-app/pom.xml clean package' - - - - } + stages { + stage('test') { + parallel { + stage('check_gradle_version') { + steps { + container('gradle') { + sh 'gradle -v' + sh 'echo workspace is $WORKSPACE' + sh "ls -la ${pwd()}" + sh 'chmod 777 * ' + sh './gradlew compileJava' + } + } + } + stage('Unit Test') { + steps { + container('gradle') { + withMaven(maven: 'MAVEN-3.6.3') { + withSonarQubeEnv(installationName: 'Sonarqube') { + echo 'I am executing unit test' + sh "ls -la ${pwd()}" + sh 'mvn -f sample-java-app/pom.xml clean package' + } + } + } } } } - } - - stage('Code Quality') { + } + stage('Code Quality') { steps { container('gradle') { withMaven(maven: 'MAVEN-3.6.3') { - withSonarQubeEnv(installationName:'Sonarqube') { - echo 'I am executing code quality using sonarqube' + withSonarQubeEnv(installationName: 'Sonarqube') { + echo 'I am executing code quality using sonarqube' sh 'mvn -f sample-java-app/pom.xml sonar:sonar' } sleep(60) diff --git a/Jenkinsfile_PROD b/Jenkinsfile_PROD new file mode 100644 index 0000000..680faeb --- /dev/null +++ b/Jenkinsfile_PROD @@ -0,0 +1,33 @@ +def propfile +pipeline { + agent { + kubernetes { + label 'SpringBootRestApp' + defaultContainer 'jnlp' + yaml """ +apiVersion: v1 +kind: Pod +metadata: +labels: + component: ci +spec: + containers: + - name: gradle + image: gradle:3.5-jdk8-alpine + command: + - cat + tty: true +""" + } + } + stages { + stage('Build & Unit Test') { + steps { + script { + propfile = readProperties(file: './project.properties') + echo propfile['USERNAME'] + } + } + } + } +} diff --git a/hello b/hello new file mode 100644 index 0000000..d0e08a8 --- /dev/null +++ b/hello @@ -0,0 +1,2 @@ +hello +hi diff --git a/hihello b/hihello new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/hihello @@ -0,0 +1 @@ +hello diff --git a/pom.xml b/pom.xml index 045cb13..b7ad07b 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,52 @@ httpclient 4.5.3 - + + org.jacoco + jacoco-maven-plugin + 0.8.3 + + + jacoco-initialize + + prepare-agent + + + + jacoco-report + test + + report + + + + + coverage-check + + check + + + target/jacoco-report + ${project.build.directory}/coverage-reports/jacoco.exec + + + CLASS + + com.asimio.demo.Application + + + + LINE + COVEREDRATIO + 80% + + + + + + + + diff --git a/project.properties b/project.properties index 45f7f69..94f6d3c 100644 --- a/project.properties +++ b/project.properties @@ -1 +1,25 @@ -servers=lxapp.2378 lxapp.656 lxapp.5376 +feature_deploy=true +javadoc=false +jacoco=false +code_quality=false + +// New variables + +GRADLE_PATH = '/opt/gradle/gradle-3.5.1/bin' +GRADLE_TASK = 'ESBAuditClient ESBAuditLog ESBErrorTranslator TaxESB FraudESB FulfillmentESB PaymentESB ESBRadial ESBAutomatedQueueRetry AlertESB OrderReconESB' +DEPLOYMENT_ARCHIVE_DIR='/home/muleadmin/stage/archive' +DEPLOYMENT_STAGE_DIR='/home/muleadmin/stage' +DEPLOYMENT_DIR='/opt/mule/latest/webapps' +WAR_FILES='AlertESB.war FraudESB.war TaxESB.war PaymentESB.war FulfillmentESB.war ESBAuditLog.war ESBAutomatedQueueRetry.war OrderReconESB.war' +ESB_BIN_PATH='/opt/mule/bin/esb_service' +ESB_WAR_FOLDERS='PaymentESB ESBAuditLog OrderReconESB FraudESB TaxESB FulfillmentESB AlertESB ESBAutomatedQueueRetry' +REQUESTID='779' +STAGE_NAME='dev3' +WORKSOFT_URI='http://pwwsftapp01/executionmanager/api' +USERNAME='devopsengineering@signetjewelers.com' +USERNAME_FEATURE_DEPLOY='muleadmin' +HOSTS_FEATURE_DEPLOY="10.6.74.90" +USERNAME_DEV_DEPLOY='muleadmin' +HOSTS_DEV_DEPLOY="10.6.74.91, 10.6.74.92" +USERNAME_RELEASE='muleadmin' +HOSTS_RELEASE_DEPLOY="10.6.74.93, 10.6.74.94" diff --git a/sample-java-app/pom.xml b/sample-java-app/pom.xml index 4b589c0..07d57e1 100644 --- a/sample-java-app/pom.xml +++ b/sample-java-app/pom.xml @@ -10,12 +10,14 @@ io.buildpacks.example sample - 0.0.1-SNAPSHOT - sample + ${revision} + + CI-Test Sample Java Application 1.8 + 1.0.0-SNAPSHOT @@ -33,7 +35,6 @@ spring-boot-starter-test test - @@ -41,12 +42,12 @@ internal Archiva Managed Internal Repository - http://35.188.92.10/repository/internal/ + https://archiva.sgn.devops.accentureanalytics.com/repository/internal/ snapshots Archiva Managed Snapshot Repository - http://35.188.92.10/repository/snapshots/ + https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/ @@ -68,6 +69,54 @@ 4.5.3 + + + org.jacoco + jacoco-maven-plugin + 0.8.3 + + + jacoco-initialize + + prepare-agent + + + + jacoco-report + test + + report + + + + + coverage-check + + check + + + target/jacoco-report + ${project.build.directory}/coverage-reports/jacoco.exec + + + CLASS + + com.asimio.demo.Application + + + + LINE + COVEREDRATIO + 80% + + + + + + + + + @@ -83,7 +132,7 @@ snapshots Archiva Managed Snapshot Repository - http://35.188.92.10/repository/snapshots/ + https://archiva.sgn.devops.accentureanalytics.com/repository/snapshots/ false