From 1da33251f35043ebb30713ebbd8624e31c64b8b6 Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Tue, 13 Jun 2023 13:57:43 -0400
Subject: [PATCH 1/5] Update sonar in Jenkins to split build into sonar scan
 and no scan build

---
 Jenkinsfile | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 8216d104..94e0802f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -118,7 +118,10 @@
     }
 
     stages {
-      stage('Build Java code') {
+      stage('Build with Sonarcloud scan') {
+        when {
+          branch 'main'
+        }
         steps {
           container('buildcontainer') {
             readTrusted 'Makefile'
@@ -127,7 +130,23 @@
             withCredentials([string(credentialsId: 'sonarcloud-token-git-eca-rest-api', variable: 'SONAR_TOKEN')]) {
               sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.login=${SONAR_TOKEN} -Dmaven.test.skip=true'
             }
-            stash name: "target", includes: "target/**/*"
+          }
+        }
+      }
+      stage('Build without Sonarcloud scan') {
+        when {
+          not {
+           branch 'main'
+          }
+        }
+
+        steps {
+          container('buildcontainer') {
+            readTrusted 'pom.xml'
+
+            sh 'make compile-java'
+            // only no-scan builds can be deployed as we don't deploy main
+            stash includes: 'target/', name: 'target'
           }
         }
       }
-- 
GitLab


From fc3001cad428bd0bc788b91a65007f099179f007 Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Tue, 13 Jun 2023 16:26:00 -0400
Subject: [PATCH 2/5] Add upstream sonarcloud url back to POM for builds

---
 pom.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pom.xml b/pom.xml
index 0905d4ab..8cd32fa8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,7 @@
     <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
     <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/jacoco-report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
     <sonar.junit.reportPath>${project.build.directory}/surefire-reports</sonar.junit.reportPath>
+    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
     <sonar.organization>eclipse-foundation-it</sonar.organization>
     <sonar.projectKey>eclipse-foundation-it_git-eca-rest-api</sonar.projectKey>
     <sonar.projectName>Git ECA REST API</sonar.projectName>
-- 
GitLab


From 62238cb770389cff1af1be5a6141025166b7c84e Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Wed, 14 Jun 2023 09:13:04 -0400
Subject: [PATCH 3/5] Update sonar scan in Jenkins to clean and verify to fix
 build

---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 94e0802f..4becfe5e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -128,7 +128,7 @@
             readTrusted 'pom.xml'
             sh 'make generate-spec'
             withCredentials([string(credentialsId: 'sonarcloud-token-git-eca-rest-api', variable: 'SONAR_TOKEN')]) {
-              sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.login=${SONAR_TOKEN} -Dmaven.test.skip=true'
+              sh 'mvn clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -B -Dsonar.login=${SONAR_TOKEN}'
             }
           }
         }
-- 
GitLab


From 09946d7f970d322b1b36bf9522f9862dc645d964 Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Wed, 14 Jun 2023 09:51:22 -0400
Subject: [PATCH 4/5] Fix missing properties that are breaking the API build

---
 src/main/resources/application-dev.properties |  4 ++++
 src/main/resources/application.properties     | 12 ++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)
 create mode 100644 src/main/resources/application-dev.properties

diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties
new file mode 100644
index 00000000..24d354e0
--- /dev/null
+++ b/src/main/resources/application-dev.properties
@@ -0,0 +1,4 @@
+## Internal dev settings to help with testing
+eclipse.cache.resource.enabled=true
+eclipse.optional-resources.enabled=true
+eclipse.scheduled.private-project.enabled=false
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 09df93d1..456b0527 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,8 +1,6 @@
 quarkus.rest-client."org.eclipsefoundation.git.eca.api.AccountsAPI".scope=javax.enterprise.context.ApplicationScoped
 quarkus.rest-client."org.eclipsefoundation.git.eca.api.AccountsAPI".url=https://api.eclipse.org
 projects-api/mp-rest/url=https://projects.eclipse.org
-eclipse.cache.loading."projects".timeout=10
-eclipse.cache.loading."projects".start-at-boot=true
 org.eclipsefoundation.git.eca.api.BotsAPI/mp-rest/url=https://api.eclipse.org
 quarkus.rest-client."org.eclipsefoundation.git.eca.api.GitlabAPI".url=https://gitlab.eclipse.org/api/v4/
 
@@ -33,14 +31,19 @@ oauth2.client-id=placeholder
 oauth2.client-secret=placeholder
 eclipse.reports.allowed-users=mbarbaro,webdev
 
+## CACHE SETTINGS
+eclipse.cache.loading."projects".timeout=10
+eclipse.cache.loading."projects".start-at-boot=true
+eclipse.cache.loading."projects".runtime-boot-key=all
+## shorter internal cache time for more live data
 quarkus.cache.caffeine."default".initial-capacity=1000
 quarkus.cache.caffeine."default".expire-after-write=15M
 quarkus.cache.caffeine."record".initial-capacity=${quarkus.cache.caffeine."default".initial-capacity}
 quarkus.cache.caffeine."record".expire-after-write=${quarkus.cache.caffeine."default".expire-after-write}
-
 ## JWT cache, 115 second cache time to make sure there is no accidental sending of an expired token
 quarkus.cache.caffeine."accesstoken".initial-capacity=1000
 quarkus.cache.caffeine."accesstoken".expire-after-write=119S
+
 ## JWT Placeholders/defaults
 smallrye.jwt.new-token.lifespan=120
 smallrye.jwt.new-token.issuer=262450
@@ -48,8 +51,5 @@ eclipse.webhooks.github.context=eclipsefdn/eca
 eclipse.webhooks.github.server-target=https://api.eclipse.org
 
 eclipse.mail.allowlist=noreply@github.com,49699333+dependabot[bot]@users.noreply.github.com,bot@stepsecurity.io
-%dev.eclipse.cache.resource.enabled=true
-%dev.eclipse.optional-resources.enabled=true
-%dev.eclipse.scheduled.private-project.enabled=false
 
 eclipse.system-hook.pool-size=5
-- 
GitLab


From 046fbacec2580e91fef619080691201e19be764f Mon Sep 17 00:00:00 2001
From: Martin Lowe <martin.lowe@eclipse-foundation.org>
Date: Wed, 14 Jun 2023 12:13:33 -0400
Subject: [PATCH 5/5] Update docker build in CI to only run on prod and staging
 branches

---
 Jenkinsfile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index 4becfe5e..099775ad 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -155,6 +155,12 @@
         agent {
           label 'docker-build'
         }
+        when {
+          anyOf {
+            environment name: 'ENVIRONMENT', value: 'production'
+            environment name: 'ENVIRONMENT', value: 'staging'
+          }
+        }
         steps {
           readTrusted 'src/main/docker/Dockerfile.jvm'
 
-- 
GitLab