From 7add8c1d73f9dde85a8fb91cec5595834ffe3385 Mon Sep 17 00:00:00 2001 From: Darin Pope Date: Fri, 13 Aug 2021 15:37:55 -0400 Subject: [PATCH 1/7] update Signed-off-by: Darin Pope --- Jenkinsfile | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 83f80749..89db387a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,42 +3,13 @@ pipeline { options { buildDiscarder(logRotator(numToKeepStr: '5')) } - environment { - HEROKU_API_KEY = credentials('darinpope-heroku-api-key') - } - parameters { - string(name: 'APP_NAME', defaultValue: '', description: 'What is the Heroku app name?') - } stages { stage('Build') { steps { - sh 'docker build -t darinpope/java-web-app:latest .' + withSonarQubeEnv(installationName: 'sq1') { + sh './mvnw org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2144:sonar' + } } } - stage('Login') { - steps { - sh 'echo $HEROKU_API_KEY | docker login --username=_ --password-stdin registry.heroku.com' - } - } - stage('Push to Heroku registry') { - steps { - sh ''' - docker tag darinpope/java-web-app:latest registry.heroku.com/$APP_NAME/web - docker push registry.heroku.com/$APP_NAME/web - ''' - } - } - stage('Release the image') { - steps { - sh ''' - heroku container:release web --app=$APP_NAME - ''' - } - } - } - post { - always { - sh 'docker logout' - } } } \ No newline at end of file From 0eb8ccc7f857dbddb3e8b22f51b09737176dbfb3 Mon Sep 17 00:00:00 2001 From: Darin Pope Date: Fri, 13 Aug 2021 15:41:13 -0400 Subject: [PATCH 2/7] fix Signed-off-by: Darin Pope --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 89db387a..afd61f85 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,10 +4,10 @@ pipeline { buildDiscarder(logRotator(numToKeepStr: '5')) } stages { - stage('Build') { + stage('Scan') { steps { withSonarQubeEnv(installationName: 'sq1') { - sh './mvnw org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2144:sonar' + sh './mvnw org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar' } } } From cd5bb8f677336b679cc7cad4656dc0afdda05158 Mon Sep 17 00:00:00 2001 From: Darin Pope Date: Fri, 13 Aug 2021 16:16:27 -0400 Subject: [PATCH 3/7] add qualityGate Signed-off-by: Darin Pope --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index afd61f85..2b1e0aaf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,5 +11,12 @@ pipeline { } } } + stage("Quality Gate") { + steps { + timeout(time: 1, unit: 'HOURS') { + waitForQualityGate abortPipeline: true + } + } + } } } \ No newline at end of file From d36c4366629be308dc651fc789fc5554da9eeaa5 Mon Sep 17 00:00:00 2001 From: Darin Pope Date: Fri, 13 Aug 2021 16:16:48 -0400 Subject: [PATCH 4/7] add clean Signed-off-by: Darin Pope --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2b1e0aaf..aebe77a0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ pipeline { stage('Scan') { steps { withSonarQubeEnv(installationName: 'sq1') { - sh './mvnw org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar' + sh './mvnw clean org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar' } } } From 57bb9abebee544763085ab5435e86dc6b2edd025 Mon Sep 17 00:00:00 2001 From: Darin Pope Date: Fri, 13 Aug 2021 16:22:44 -0400 Subject: [PATCH 5/7] change timeout Signed-off-by: Darin Pope --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index aebe77a0..cf293943 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ pipeline { } stage("Quality Gate") { steps { - timeout(time: 1, unit: 'HOURS') { + timeout(time: 2, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } } From 1bd90bf37e613b30268de07dc429c9c4ac0a3ba8 Mon Sep 17 00:00:00 2001 From: Darin Pope Date: Fri, 13 Aug 2021 16:33:16 -0400 Subject: [PATCH 6/7] update Signed-off-by: Darin Pope --- Jenkinsfile-1 | 15 +++++++++++++++ Jenkinsfile => Jenkinsfile-2 | 0 2 files changed, 15 insertions(+) create mode 100644 Jenkinsfile-1 rename Jenkinsfile => Jenkinsfile-2 (100%) diff --git a/Jenkinsfile-1 b/Jenkinsfile-1 new file mode 100644 index 00000000..4edf935f --- /dev/null +++ b/Jenkinsfile-1 @@ -0,0 +1,15 @@ +pipeline { + agent { label 'linux' } + options { + buildDiscarder(logRotator(numToKeepStr: '5')) + } + stages { + stage('Scan') { + steps { + withSonarQubeEnv(installationName: 'sq1') { + sh './mvnw clean org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar' + } + } + } + } +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile-2 similarity index 100% rename from Jenkinsfile rename to Jenkinsfile-2 From 9c24ff6d594faaf440c4dcce27e991bf38e872d6 Mon Sep 17 00:00:00 2001 From: ajithcsedep <105938981+ajithcsedep@users.noreply.github.com> Date: Wed, 30 Nov 2022 16:05:31 +0530 Subject: [PATCH 7/7] Update Jenkinsfile-1 --- Jenkinsfile-1 | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile-1 b/Jenkinsfile-1 index 4edf935f..b73a94a5 100644 --- a/Jenkinsfile-1 +++ b/Jenkinsfile-1 @@ -3,13 +3,10 @@ pipeline { options { buildDiscarder(logRotator(numToKeepStr: '5')) } - stages { - stage('Scan') { - steps { - withSonarQubeEnv(installationName: 'sq1') { - sh './mvnw clean org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar' - } - } + stage('SonarQube Analysis') { + def mvn = tool 'Default Maven'; + withSonarQubeEnv() { + sh "${mvn}/bin/mvn clean verify sonar:sonar -Dsonar.projectKey=ajith" } } -} \ No newline at end of file +}