From 27c1a29a939772f790b4a6ea301950e68a74a656 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Mon, 28 Jan 2019 13:24:24 -0800 Subject: [PATCH 01/26] Added JenkinsFile --- Jenkinsfile | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..5aa024139b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,175 @@ +@Library('shared-libraries') _ +def gitDataHubRepo="https://github.com/SameeraPriyathamTadikonda/marklogic-data-hub.git" +def JAVA_HOME="~/java/jdk1.8.0_72" +def GRADLE_USER_HOME="/.gradle" +def MAVEN_HOME="/usr/local/maven" +pipeline{ + agent none; + options { + checkoutToSubdirectory 'data-hub' + } + stages{ + stage('Build-datahub'){ + agent { label 'dhfLinuxAgent'} + steps{ + script{ + if(env.CHANGE_TITLE){ + def transitionInput =[transition: [id: '41']] + jiraTransitionIssue idOrKey: env.CHANGE_TITLE, input: transitionInput, site: 'JIRA' + } + } + println(BRANCH_NAME) + sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew build -x test -Pskipui=true;' + archiveArtifacts artifacts: 'data-hub/marklogic-data-hub/build/libs/* , data-hub/ml-data-hub-plugin/build/libs/* , data-hub/quick-start/build/libs/', onlyIfSuccessful: true } + } + stage('Unit-Tests'){ + agent { label 'dhfLinuxAgent'} + steps{ + copyRPM 'Latest' + setUpML '$WORKSPACE/xdmp/src/Mark*.rpm' + sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew :marklogic-data-hub:test --tests com.marklogic.hub.flow.* -Pskipui=true' + junit '**/TEST-*.xml' + script{ + if(env.CHANGE_TITLE){ + jiraAddComment comment: 'Jenkins Unit Test Results For PR Available', idOrKey: env.CHANGE_TITLE, site: 'JIRA' + } + } + } + post{ + success { + println("Unit Tests Completed") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Unit Tests for PR $CHANGE_ID Passed' + } + failure { + println("Unit Tests Failed") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Unit Tests for PR $CHANGE_ID Failed' + } + } + } + stage('code-review'){ + when { + changeRequest() + beforeAgent true + } + agent none; + steps{ + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Waiting for code review PR $CHANGE_ID ' + script{ + try{ + timeout(time:5, unit:'MINUTES') { + input message:'Review Done?' + } + }catch(err){ + currentBuild.result = "SUCCESS" + } + } + } + } + stage('PR'){ + when { + changeRequest() + beforeAgent true + } + agent {label 'master'}; + steps{ + retry(5){ + withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { + script{ + + def response = sh (returnStdout: true, script:'''curl -u $Credentials --header "application/vnd.github.merge-info-preview+json" "https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/$CHANGE_ID" | grep '"mergeable_state":' | cut -d ':' -f2 | cut -d ',' -f1 | tr -d '"' ''') + response=response.trim(); + println(response) + if(response.equals("clean")){ + println("merging can be done") + sh "curl -o - -s -w \"\n%{http_code}\n\" -X PUT -d '{\"commit_title\": \"Merge pull request\"}' -u $Credentials https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/$CHANGE_ID/merge | tail -1 > mergeResult.txt" + def mergeResult = readFile('mergeResult.txt').trim() + if(mergeResult==200){ + println("Merge successful") + }else{ + println("Merge Failed") + } + }else if(response.equals("blocked")){ + println("retry blocked"); + sleep time: 1, unit: 'MINUTES' + throw new Exception("Waiting for all the status checks to pass"); + }else if(response.equals("unstable")){ + println("retry unstable") + sh "curl -o - -s -w \"\n%{http_code}\n\" -X PUT -d '{\"commit_title\": \"Merge pull request\"}' -u $Credentials https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/$CHANGE_ID/merge | tail -1 > mergeResult.txt" + def mergeResult = readFile('mergeResult.txt').trim() + println("Result is"+ mergeResult) + }else{ + println("merging not possible") + currentBuild.result = "FAILURE" + sh 'exit 1'; + } + } + } + } + } + post{ + success { + println("Merge Successful") + script{ + if(env.CHANGE_TITLE){ + def transitionInput =[transition: [id: '31']] + jiraTransitionIssue idOrKey: env.CHANGE_TITLE, input: transitionInput, site: 'JIRA' + } + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,' PR $CHANGE_ID is Merged' + } + } + failure { + println("Retried 5times") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'PR $CHANGE_ID Cannot be Merged' + } + } + } + stage('End-End Tests'){ + agent { label 'dhfLinuxAgent'} + steps{ + copyRPM 'Latest' + setUpML '$WORKSPACE/xdmp/src/Mark*.rpm' + sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew :marklogic-data-hub:test --tests com.marklogic.hub.flow.* -Pskipui=true' + junit '**/TEST-*.xml' + script{ + if(env.CHANGE_TITLE){ + jiraAddComment comment: 'Jenkins End-End Unit Test Results For PR Available', idOrKey: env.CHANGE_TITLE, site: 'JIRA' + } + } + } + post{ + success { + println("End-End Tests Completed") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Passed' + } + failure { + println("End-End Tests Failed") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Failed' + } + } + } + stage('Create PR For Release Branch'){ + when { + changeRequest() + beforeAgent true + } + agent {label 'master'} + steps{ + withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { + script{ + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"new PR for Release Branch\" , \"head\": \"develop\" , \"base\": \"PR_DEV\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + } + } + } + post{ + success { + println("PR For Release branch created") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Passed' + } + failure { + println("End-End Tests Failed") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Failed' + } + } + } + } +} \ No newline at end of file From 3b70da7bde6525dded02dabbf90cb135eab07e53 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Mon, 28 Jan 2019 14:38:24 -0800 Subject: [PATCH 02/26] Added conditions for stages --- Jenkinsfile | 63 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5aa024139b..4fbce48637 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,7 +48,9 @@ pipeline{ } stage('code-review'){ when { - changeRequest() + allOf { + changeRequest author: '', authorDisplayName: '', authorEmail: '', branch: '', fork: '', id: '', target: '', title: '', url: '' + } beforeAgent true } agent none; @@ -123,7 +125,7 @@ pipeline{ } } } - stage('End-End Tests'){ + stage('Integration Tests'){ agent { label 'dhfLinuxAgent'} steps{ copyRPM 'Latest' @@ -147,29 +149,76 @@ pipeline{ } } } - stage('Create PR For Release Branch'){ + stage('Create PR For Integration Branch'){ when { - changeRequest() + changeRequest target: 'FeatureBranch' beforeAgent true } agent {label 'master'} steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"new PR for Release Branch\" , \"head\": \"develop\" , \"base\": \"PR_DEV\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } } post{ success { - println("PR For Release branch created") + println("Automated PR For Integration branch created") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Integration Tests for PR $CHANGE_ID Passed' + } + failure { + println("Creation of Automated PR Failed") + + } + } + } + stage('Upgrade Tests'){ + agent { label 'dhfLinuxAgent'} + steps{ + copyRPM 'Latest' + setUpML '$WORKSPACE/xdmp/src/Mark*.rpm' + sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew :marklogic-data-hub:test --tests com.marklogic.hub.flow.* -Pskipui=true' + junit '**/TEST-*.xml' + script{ + if(env.CHANGE_TITLE){ + jiraAddComment comment: 'Jenkins Upgrade Test Results For PR Available', idOrKey: env.CHANGE_TITLE, site: 'JIRA' + } + } + } + post{ + success { + println("Upgrade Tests Completed") sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Passed' } failure { - println("End-End Tests Failed") + println("Upgrade Tests Failed") sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Failed' } } } + stage('Create PR For Release Branch'){ + when { + changeRequest comparator: 'REGEXP', target: 'Integration*' + beforeAgent true + } + agent {label 'master'} + steps{ + withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { + script{ + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + } + } + } + post{ + success { + println("Automated PR For Release branch created") + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Integration Tests for PR $CHANGE_ID Passed' + } + failure { + println("Creation of Automated PR Failed") + } + } + } } } \ No newline at end of file From e434e10f81e76250da000d80d756bcc72b875255 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Wed, 30 Jan 2019 13:50:17 -0800 Subject: [PATCH 03/26] Added JIRA Task --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4fbce48637..cb03d45e15 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -158,7 +158,7 @@ pipeline{ steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${CHANGE_TITLE} Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } } @@ -206,7 +206,7 @@ pipeline{ steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${CHANGE_TITLE} Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } } From 9d1cfa6c4601164ce0931edc8e3a4e6c4998ff7d Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Wed, 30 Jan 2019 16:16:18 -0800 Subject: [PATCH 04/26] getting JIRA ID from PR Title --- Jenkinsfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cb03d45e15..cd2122461c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ def gitDataHubRepo="https://github.com/SameeraPriyathamTadikonda/marklogic-data- def JAVA_HOME="~/java/jdk1.8.0_72" def GRADLE_USER_HOME="/.gradle" def MAVEN_HOME="/usr/local/maven" +def JIRA_ID=""; pipeline{ agent none; options { @@ -14,8 +15,9 @@ pipeline{ steps{ script{ if(env.CHANGE_TITLE){ + JIRA_ID=env.CHANGE_TITLE.split(':')[0]; def transitionInput =[transition: [id: '41']] - jiraTransitionIssue idOrKey: env.CHANGE_TITLE, input: transitionInput, site: 'JIRA' + jiraTransitionIssue idOrKey: JIRA_ID, input: transitionInput, site: 'JIRA' } } println(BRANCH_NAME) @@ -31,7 +33,7 @@ pipeline{ junit '**/TEST-*.xml' script{ if(env.CHANGE_TITLE){ - jiraAddComment comment: 'Jenkins Unit Test Results For PR Available', idOrKey: env.CHANGE_TITLE, site: 'JIRA' + jiraAddComment comment: 'Jenkins Unit Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA' } } } @@ -114,7 +116,7 @@ pipeline{ script{ if(env.CHANGE_TITLE){ def transitionInput =[transition: [id: '31']] - jiraTransitionIssue idOrKey: env.CHANGE_TITLE, input: transitionInput, site: 'JIRA' + jiraTransitionIssue idOrKey: JIRA_ID, input: transitionInput, site: 'JIRA' } sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,' PR $CHANGE_ID is Merged' } @@ -134,7 +136,7 @@ pipeline{ junit '**/TEST-*.xml' script{ if(env.CHANGE_TITLE){ - jiraAddComment comment: 'Jenkins End-End Unit Test Results For PR Available', idOrKey: env.CHANGE_TITLE, site: 'JIRA' + jiraAddComment comment: 'Jenkins End-End Unit Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA' } } } @@ -158,7 +160,7 @@ pipeline{ steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${CHANGE_TITLE} Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } } @@ -182,7 +184,7 @@ pipeline{ junit '**/TEST-*.xml' script{ if(env.CHANGE_TITLE){ - jiraAddComment comment: 'Jenkins Upgrade Test Results For PR Available', idOrKey: env.CHANGE_TITLE, site: 'JIRA' + jiraAddComment comment: 'Jenkins Upgrade Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA' } } } @@ -206,7 +208,7 @@ pipeline{ steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${CHANGE_TITLE} Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } } From d86457c5c7bafc874822f4945be290fc3c07b180 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 08:51:09 -0800 Subject: [PATCH 05/26] Updated email notification and Jira Number --- Jenkinsfile | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cd2122461c..e22ad27e03 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,6 +33,7 @@ pipeline{ junit '**/TEST-*.xml' script{ if(env.CHANGE_TITLE){ + JIRA_ID=env.CHANGE_TITLE.split(':')[0] jiraAddComment comment: 'Jenkins Unit Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA' } } @@ -40,11 +41,11 @@ pipeline{ post{ success { println("Unit Tests Completed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Unit Tests for PR $CHANGE_ID Passed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Unit Tests for $BRANCH_NAME Passed' } failure { println("Unit Tests Failed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Unit Tests for PR $CHANGE_ID Failed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Unit Tests for $BRANCH_NAME Failed' } } } @@ -57,7 +58,7 @@ pipeline{ } agent none; steps{ - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Waiting for code review PR $CHANGE_ID ' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Waiting for code review $BRANCH_NAME ' script{ try{ timeout(time:5, unit:'MINUTES') { @@ -116,14 +117,15 @@ pipeline{ script{ if(env.CHANGE_TITLE){ def transitionInput =[transition: [id: '31']] + JIRA_ID=env.CHANGE_TITLE.split(':')[0] jiraTransitionIssue idOrKey: JIRA_ID, input: transitionInput, site: 'JIRA' } - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,' PR $CHANGE_ID is Merged' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,' $BRANCH_NAME is Merged' } } failure { println("Retried 5times") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'PR $CHANGE_ID Cannot be Merged' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,' $BRANCH_NAME Cannot be Merged' } } } @@ -136,6 +138,7 @@ pipeline{ junit '**/TEST-*.xml' script{ if(env.CHANGE_TITLE){ + JIRA_ID=env.CHANGE_TITLE.split(':')[0] jiraAddComment comment: 'Jenkins End-End Unit Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA' } } @@ -143,11 +146,11 @@ pipeline{ post{ success { println("End-End Tests Completed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Passed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for $BRANCH_NAME Passed' } failure { println("End-End Tests Failed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Failed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for $BRANCH_NAME Failed' } } } @@ -160,6 +163,7 @@ pipeline{ steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ + JIRA_ID=env.CHANGE_TITLE.split(':')[0] sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } @@ -167,7 +171,6 @@ pipeline{ post{ success { println("Automated PR For Integration branch created") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Integration Tests for PR $CHANGE_ID Passed' } failure { println("Creation of Automated PR Failed") @@ -184,6 +187,7 @@ pipeline{ junit '**/TEST-*.xml' script{ if(env.CHANGE_TITLE){ + JIRA_ID=env.CHANGE_TITLE.split(':')[0] jiraAddComment comment: 'Jenkins Upgrade Test Results For PR Available', idOrKey: JIRA_ID, site: 'JIRA' } } @@ -191,11 +195,11 @@ pipeline{ post{ success { println("Upgrade Tests Completed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Passed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for $BRANCH_NAME Passed' } failure { println("Upgrade Tests Failed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for PR $CHANGE_ID Failed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for $BRANCH_NAME Failed' } } } @@ -208,6 +212,7 @@ pipeline{ steps{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ + JIRA_ID=env.CHANGE_TITLE.split(':')[0] sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" } } @@ -215,7 +220,6 @@ pipeline{ post{ success { println("Automated PR For Release branch created") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Integration Tests for PR $CHANGE_ID Passed' } failure { println("Creation of Automated PR Failed") From d97b39ef2d7347985b31942ff316db407d0e44d8 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 10:06:45 -0800 Subject: [PATCH 06/26] Added timeout conditions --- Jenkinsfile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e22ad27e03..8eb439177d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,8 @@ def JAVA_HOME="~/java/jdk1.8.0_72" def GRADLE_USER_HOME="/.gradle" def MAVEN_HOME="/usr/local/maven" def JIRA_ID=""; +def userInput = true +def didTimeout = false pipeline{ agent none; options { @@ -62,10 +64,22 @@ pipeline{ script{ try{ timeout(time:5, unit:'MINUTES') { - input message:'Review Done?' + userInput = (input message:'Review Done?', parameters: [ + [$class: 'BooleanParameterDefinition', defaultValue: true] + ]) } }catch(err){ - currentBuild.result = "SUCCESS" + script{ + def user = err.getCauses()[0].getUser() + if('SYSTEM' == user.toString()) { // SYSTEM means timeout. + didTimeout = true + currentBuild.result = "SUCCESS" + } else { + userInput = false + echo "Aborted by: [${user}]" + sh 'exit 1'; + } + } } } } @@ -195,11 +209,11 @@ pipeline{ post{ success { println("Upgrade Tests Completed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for $BRANCH_NAME Passed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Upgrade Tests for $BRANCH_NAME Passed' } failure { println("Upgrade Tests Failed") - sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'End-End Tests for $BRANCH_NAME Failed' + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Upgrade Tests for $BRANCH_NAME Failed' } } } From e9296a7c3d4cf740e56bdf93c36c522cf4d24c27 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 10:17:45 -0800 Subject: [PATCH 07/26] Added timeout conditions --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8eb439177d..b5c7121d38 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,9 +64,7 @@ pipeline{ script{ try{ timeout(time:5, unit:'MINUTES') { - userInput = (input message:'Review Done?', parameters: [ - [$class: 'BooleanParameterDefinition', defaultValue: true] - ]) + userInput = ( input message:'Review Done?', parameters: [$class: 'BooleanParameterDefinition', defaultValue: true]) } }catch(err){ script{ From ce81a9bfcbd206995175fc74f736b6f1536b7e94 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 10:21:32 -0800 Subject: [PATCH 08/26] Added timeout conditions --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b5c7121d38..1f5955b343 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,7 +64,9 @@ pipeline{ script{ try{ timeout(time:5, unit:'MINUTES') { - userInput = ( input message:'Review Done?', parameters: [$class: 'BooleanParameterDefinition', defaultValue: true]) + input message:'Review Done?', parameters { + string(name:'username', defaultValue: 'user', description: 'Username of the user pressing Ok') + } } }catch(err){ script{ From 98793b6a1a7e68c6d3253892bd7660aaa710c3f1 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 11:59:30 -0800 Subject: [PATCH 09/26] Added timeout conditions --- Jenkinsfile | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1f5955b343..c5281affaf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,8 +4,6 @@ def JAVA_HOME="~/java/jdk1.8.0_72" def GRADLE_USER_HOME="/.gradle" def MAVEN_HOME="/usr/local/maven" def JIRA_ID=""; -def userInput = true -def didTimeout = false pipeline{ agent none; options { @@ -64,22 +62,10 @@ pipeline{ script{ try{ timeout(time:5, unit:'MINUTES') { - input message:'Review Done?', parameters { - string(name:'username', defaultValue: 'user', description: 'Username of the user pressing Ok') - } + input message:'Review Done?' } }catch(err){ - script{ - def user = err.getCauses()[0].getUser() - if('SYSTEM' == user.toString()) { // SYSTEM means timeout. - didTimeout = true - currentBuild.result = "SUCCESS" - } else { - userInput = false - echo "Aborted by: [${user}]" - sh 'exit 1'; - } - } + currentBuild.result = "SUCCESS" } } } @@ -234,6 +220,7 @@ pipeline{ post{ success { println("Automated PR For Release branch created") + } failure { println("Creation of Automated PR Failed") From 04b321c9ace1147278690b315e1e15789de8f782 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 12:30:38 -0800 Subject: [PATCH 10/26] Added REGEXP Condition --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c5281affaf..de23884218 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -205,7 +205,7 @@ pipeline{ } stage('Create PR For Release Branch'){ when { - changeRequest comparator: 'REGEXP', target: 'Integration*' + changeRequest comparator: 'REGEXP', target: 'Integration[*]' beforeAgent true } agent {label 'master'} From 488285f8072a2971aa5863230bb51de48fa6b26e Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 15:51:17 -0800 Subject: [PATCH 11/26] Added REGEXP Condition --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index de23884218..d00c581abd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -205,7 +205,7 @@ pipeline{ } stage('Create PR For Release Branch'){ when { - changeRequest comparator: 'REGEXP', target: 'Integration[*]' + changeRequest target: 'IntegrationBranch' beforeAgent true } agent {label 'master'} From 19374f1b64cb7f7c7742528048025d309f6691a8 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 17:35:42 -0800 Subject: [PATCH 12/26] Skip code review if its automated PR --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index d00c581abd..6b992c517b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,6 +58,12 @@ pipeline{ } agent none; steps{ + script{ + if(env.CHANGE_TITLE.split(':')[1].contains("Automated PR")){ + println("Automated PR") + sh 'exit 0' + } + } sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Waiting for code review $BRANCH_NAME ' script{ try{ From 3415104e49bf18403ed5a7f8576425387f5c9180 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 20:17:02 -0800 Subject: [PATCH 13/26] added agent --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b992c517b..c1d3dec9b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,7 +56,7 @@ pipeline{ } beforeAgent true } - agent none; + agent {label 'master'}; steps{ script{ if(env.CHANGE_TITLE.split(':')[1].contains("Automated PR")){ From c84ebf296ec24478f037b0ad20326c0ed6c19853 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 21:17:15 -0800 Subject: [PATCH 14/26] Automatic Approvals and code-reviews --- Jenkinsfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c1d3dec9b5..85abf57233 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,10 +62,9 @@ pipeline{ if(env.CHANGE_TITLE.split(':')[1].contains("Automated PR")){ println("Automated PR") sh 'exit 0' - } - } + }else{ + sendMail 'stadikon@marklogic.com','Check: ${BUILD_URL}/console',false,'Waiting for code review $BRANCH_NAME ' - script{ try{ timeout(time:5, unit:'MINUTES') { input message:'Review Done?' @@ -73,6 +72,7 @@ pipeline{ }catch(err){ currentBuild.result = "SUCCESS" } + } } } } @@ -170,9 +170,16 @@ pipeline{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ JIRA_ID=env.CHANGE_TITLE.split(':')[0] - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + def prResponse = sh (returnStdout: true, script:''' + curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') + def prNumber=sh (returnStdout: true, script:''' $prResponse | grep '"number":' | cut -d ':' -f2 ''') + } } + withCredentials([usernameColonPassword(credentialsId: 'rahul-git', variable: 'Credentials')]) { + sh "curl -u $Credentials -X POST -d '{\"event\": \"APPROVE\"}' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/$prNumber/reviews" + } + } post{ success { From 837702ec82572c55562abeb500c8a5fdd6633aec Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Thu, 31 Jan 2019 21:34:32 -0800 Subject: [PATCH 15/26] Automatic Approvals and code-reviews --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85abf57233..d5f1f10b1d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -173,11 +173,12 @@ pipeline{ def prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') def prNumber=sh (returnStdout: true, script:''' $prResponse | grep '"number":' | cut -d ':' -f2 ''') + println(prNumber) } } withCredentials([usernameColonPassword(credentialsId: 'rahul-git', variable: 'Credentials')]) { - sh "curl -u $Credentials -X POST -d '{\"event\": \"APPROVE\"}' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/$prNumber/reviews" + sh "curl -u $Credentials -X POST -d '{\"event\": \"APPROVE\"}' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/${prNumber}/reviews" } } From 4608f029dacca0a910cbabb87cbaadac7f2f47cc Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 09:27:49 -0800 Subject: [PATCH 16/26] updated PRresponse code --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d5f1f10b1d..2923e30191 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -171,7 +171,8 @@ pipeline{ script{ JIRA_ID=env.CHANGE_TITLE.split(':')[0] def prResponse = sh (returnStdout: true, script:''' - curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') + curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') + println(prResponse) def prNumber=sh (returnStdout: true, script:''' $prResponse | grep '"number":' | cut -d ':' -f2 ''') println(prNumber) From 29ecfcdca0dbcf759d2704b5c2bbe1afd354afdb Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 09:45:08 -0800 Subject: [PATCH 17/26] added echo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2923e30191..86a3be83f9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -173,7 +173,7 @@ pipeline{ def prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') println(prResponse) - def prNumber=sh (returnStdout: true, script:''' $prResponse | grep '"number":' | cut -d ':' -f2 ''') + def prNumber=sh (returnStdout: true, script:''' echo $prResponse | grep '"number":' | cut -d ':' -f2 ''') println(prNumber) } From 41a7af6a7f1f604f262d57beb981e044c373ba45 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 10:28:09 -0800 Subject: [PATCH 18/26] added to the global variables --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 86a3be83f9..8c270ea2ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,8 @@ def JAVA_HOME="~/java/jdk1.8.0_72" def GRADLE_USER_HOME="/.gradle" def MAVEN_HOME="/usr/local/maven" def JIRA_ID=""; +def prResponse=""; +def prNumber; pipeline{ agent none; options { @@ -170,7 +172,7 @@ pipeline{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ JIRA_ID=env.CHANGE_TITLE.split(':')[0] - def prResponse = sh (returnStdout: true, script:''' + prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') println(prResponse) def prNumber=sh (returnStdout: true, script:''' echo $prResponse | grep '"number":' | cut -d ':' -f2 ''') From 84d7698489d021ebd2903387393f8628d2b28fb3 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 10:29:03 -0800 Subject: [PATCH 19/26] added to the global variables --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8c270ea2ad..62f225aa54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -175,7 +175,7 @@ pipeline{ prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') println(prResponse) - def prNumber=sh (returnStdout: true, script:''' echo $prResponse | grep '"number":' | cut -d ':' -f2 ''') + prNumber=sh (returnStdout: true, script:''' echo $prResponse | grep '"number":' | cut -d ':' -f2 ''') println(prNumber) } From c38ac62910c5c5fccf56e06df03d56b6e5114ce4 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 11:10:56 -0800 Subject: [PATCH 20/26] added to the global variables --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 62f225aa54..b1879dbb8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -175,7 +175,7 @@ pipeline{ prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') println(prResponse) - prNumber=sh (returnStdout: true, script:''' echo $prResponse | grep '"number":' | cut -d ':' -f2 ''') + prNumber=sh (returnStdout: true, script:''' echo '''+prResponse +'''| grep '"number":' | cut -d ':' -f2 ''') println(prNumber) } From af1b149a49d5ade2b7ade3c6b50c1a8835179dfa Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 11:34:01 -0800 Subject: [PATCH 21/26] updated the cut command --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b1879dbb8f..bc3b9f5fa4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -175,7 +175,7 @@ pipeline{ prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') println(prResponse) - prNumber=sh (returnStdout: true, script:''' echo '''+prResponse +'''| grep '"number":' | cut -d ':' -f2 ''') + prNumber=sh (returnStdout: true, script:''' echo '''+prResponse +'''| grep '"number":' | cut -d ':' -f2 | cut -d ',' -f1 | tr -d ''') println(prNumber) } From 2aa054736624a336a0be07ff2bb470c78357f6f2 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 13:19:09 -0800 Subject: [PATCH 22/26] Added json Surpler --- Jenkinsfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc3b9f5fa4..528522b4d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,5 @@ @Library('shared-libraries') _ +import groovy.json.JsonSlurper def gitDataHubRepo="https://github.com/SameeraPriyathamTadikonda/marklogic-data-hub.git" def JAVA_HOME="~/java/jdk1.8.0_72" def GRADLE_USER_HOME="/.gradle" @@ -175,9 +176,9 @@ pipeline{ prResponse = sh (returnStdout: true, script:''' curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Integration Branch\" , \"head\": \"FeatureBranch\" , \"base\": \"IntegrationBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls ''') println(prResponse) - prNumber=sh (returnStdout: true, script:''' echo '''+prResponse +'''| grep '"number":' | cut -d ':' -f2 | cut -d ',' -f1 | tr -d ''') - println(prNumber) - + def slurper = new JsonSlurper().parseText(prResponse) + println(slurper.number) + prNumber=slurper.number; } } withCredentials([usernameColonPassword(credentialsId: 'rahul-git', variable: 'Credentials')]) { From 1255b90c6274cad38d2beb37d7631722286668e0 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 15:33:12 -0800 Subject: [PATCH 23/26] Added Automatic Approvals for PR --- Jenkinsfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 528522b4d9..23ab33ed08 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -231,9 +231,19 @@ pipeline{ withCredentials([usernameColonPassword(credentialsId: 'a0ec09aa-f339-44de-87c4-1a4936df44f5', variable: 'Credentials')]) { script{ JIRA_ID=env.CHANGE_TITLE.split(':')[0] - sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"${JIRA_ID}: Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls" + prResponse = sh (returnStdout: true, script:''' + sh "curl -u $Credentials -X POST -H 'Content-Type:application/json' -d '{\"title\": \"'''+JIRA_ID+''': Automated PR for Release Branch\" , \"head\": \"IntegrationBranch\" , \"base\": \"ReleaseBranch\" }' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls"''') + println(prResponse) + def slurper = new JsonSlurper().parseText(prResponse) + println(slurper.number) + prNumber=slurper.number; } } + withCredentials([usernameColonPassword(credentialsId: 'rahul-git', variable: 'Credentials')]) { + sh "curl -u $Credentials -X POST -d '{\"event\": \"APPROVE\"}' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/${prNumber}/reviews" + } + + } } post{ success { From 888ac0da24d8dba815f97d2d53bd85d45a6f8766 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 15:35:44 -0800 Subject: [PATCH 24/26] Added Automatic Approvals for PR --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 23ab33ed08..68b7defc23 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -254,6 +254,5 @@ pipeline{ println("Creation of Automated PR Failed") } } - } } } \ No newline at end of file From ede2bd0af6f6197c63e3638b144f425ccbd02980 Mon Sep 17 00:00:00 2001 From: SameeraPriyathamTadikonda Date: Fri, 1 Feb 2019 15:36:50 -0800 Subject: [PATCH 25/26] Added Automatic Approvals for PR --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 68b7defc23..3e2f13e34e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -243,7 +243,6 @@ pipeline{ sh "curl -u $Credentials -X POST -d '{\"event\": \"APPROVE\"}' https://api.github.com/repos/SameeraPriyathamTadikonda/marklogic-data-hub/pulls/${prNumber}/reviews" } - } } post{ success { @@ -254,5 +253,6 @@ pipeline{ println("Creation of Automated PR Failed") } } + } } } \ No newline at end of file From b06b2cb37d63903c6c740e3af8f1078f647843ba Mon Sep 17 00:00:00 2001 From: kkanthet Date: Wed, 6 Feb 2019 16:22:49 -0800 Subject: [PATCH 26/26] Update Jenkins file with local ML rpm Update Jenkins file with local ML rpm --- Jenkinsfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3e2f13e34e..4da40178e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ @Library('shared-libraries') _ import groovy.json.JsonSlurper -def gitDataHubRepo="https://github.com/SameeraPriyathamTadikonda/marklogic-data-hub.git" -def JAVA_HOME="~/java/jdk1.8.0_72" +//def gitDataHubRepo="https://github.com/SameeraPriyathamTadikonda/marklogic-data-hub.git" +//def JAVA_HOME="~/java/jdk1.8.0_72" def GRADLE_USER_HOME="/.gradle" def MAVEN_HOME="/usr/local/maven" def JIRA_ID=""; @@ -30,8 +30,8 @@ pipeline{ stage('Unit-Tests'){ agent { label 'dhfLinuxAgent'} steps{ - copyRPM 'Latest' - setUpML '$WORKSPACE/xdmp/src/Mark*.rpm' + //copyRPM 'Latest' + setUpML '/home/ec2-user/MarkLogic-9.0-8.1.x86_64.rpm' //'$WORKSPACE/xdmp/src/Mark*.rpm' sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew :marklogic-data-hub:test --tests com.marklogic.hub.flow.* -Pskipui=true' junit '**/TEST-*.xml' script{ @@ -141,8 +141,8 @@ pipeline{ stage('Integration Tests'){ agent { label 'dhfLinuxAgent'} steps{ - copyRPM 'Latest' - setUpML '$WORKSPACE/xdmp/src/Mark*.rpm' + //copyRPM 'Latest' + setUpML '/home/ec2-user/MarkLogic-9.0-8.1.x86_64.rpm' //'$WORKSPACE/xdmp/src/Mark*.rpm' sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew :marklogic-data-hub:test --tests com.marklogic.hub.flow.* -Pskipui=true' junit '**/TEST-*.xml' script{ @@ -199,8 +199,8 @@ pipeline{ stage('Upgrade Tests'){ agent { label 'dhfLinuxAgent'} steps{ - copyRPM 'Latest' - setUpML '$WORKSPACE/xdmp/src/Mark*.rpm' + //copyRPM 'Latest' + setUpML '/home/ec2-user/MarkLogic-9.0-8.1.x86_64.rpm' //'$WORKSPACE/xdmp/src/Mark*.rpm' sh 'echo '+JAVA_HOME+'export '+JAVA_HOME+' export $WORKSPACE/data-hub'+GRADLE_USER_HOME+'export '+MAVEN_HOME+'export PATH=$PATH:$MAVEN_HOME/bin; cd $WORKSPACE/data-hub;rm -rf $GRADLE_USER_HOME/caches;./gradlew clean;./gradlew clean;./gradlew :marklogic-data-hub:test --tests com.marklogic.hub.flow.* -Pskipui=true' junit '**/TEST-*.xml' script{ @@ -255,4 +255,4 @@ pipeline{ } } } -} \ No newline at end of file +}