diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 52163df56..546c11421 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -9,10 +9,15 @@ jobs:
- name: Checkout
uses: actions/checkout@v2.0.0
+ - name: check the value of github.workspace and runner.temp
+ run: |
+ echo "github.workspace = ${{ github.workspace }}"
+ echo "runner.temp = ${{ runner.temp }}"
+
- name: Set up OpenJDK 11
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v3
with:
- distribution: 'adopt'
+ distribution: 'temurin'
java-version: '11'
check-latest: true
@@ -25,7 +30,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Build with Gradle
- run: ./gradlew clean build
+ run: ./gradlew -Djava.io.tmpdir=${{ runner.temp }} clean build
env:
NO_NEXUS: true
@@ -44,7 +49,7 @@ jobs:
- name: Test Report
uses: actions/upload-artifact@v2
- if: ${{ failure() }}
+ if: ${{ always() }}
with:
name: Test Report
path: build/reports/tests/test/
diff --git a/.gitignore b/.gitignore
index 8b31f5b9d..7a96d4073 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,8 @@
/.project
/gradle.properties
+/lib/*.jar
+
.idea
*.iws
*.iml
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45d59d744..293a58b9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -82,7 +82,7 @@
- Add new Infrastructure Service ([#740](https://github.com/opendevstack/ods-jenkins-shared-library/pull/740))
- Add annotation to agents by default ([#879](https://github.com/opendevstack/ods-jenkins-shared-library/issues/879))
- Fixed uploading of artifacts to 'pypi' repositories ([#785](https://github.com/opendevstack/ods-jenkins-shared-library/issues/785))
-
+- Improve memory cleanUp ([#902](https://github.com/opendevstack/ods-jenkins-shared-library/pull/902))
## [3.0] - 2020-08-11
diff --git a/build.gradle b/build.gradle
index 2db3a6ba8..fa984ce68 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,6 @@ plugins {
group "org.ods"
version = '0.0.1-SNAPSHOT'
-sourceCompatibility = 1.8
ext {
nexus_url = project.findProperty('nexus_url') ?: System.getenv('NEXUS_URL') ?: System.getenv('NEXUS_HOST')
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a4f0001d2..aa991fcea 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/org/ods/component/Pipeline.groovy b/src/org/ods/component/Pipeline.groovy
index ed9f01f91..92dc221d5 100644
--- a/src/org/ods/component/Pipeline.groovy
+++ b/src/org/ods/component/Pipeline.groovy
@@ -1,16 +1,16 @@
package org.ods.component
-import org.ods.services.GitService
+import groovy.json.JsonOutput
import org.ods.services.BitbucketService
+import org.ods.services.GitService
+import org.ods.services.JenkinsService
+import org.ods.services.NexusService
import org.ods.services.OpenShiftService
import org.ods.services.ServiceRegistry
import org.ods.util.GitCredentialStore
import org.ods.util.ILogger
import org.ods.util.IPipelineSteps
import org.ods.util.PipelineSteps
-import org.ods.services.JenkinsService
-import org.ods.services.NexusService
-import groovy.json.JsonOutput
class Pipeline implements Serializable {
@@ -19,9 +19,9 @@ class Pipeline implements Serializable {
private JenkinsService jenkinsService
private BitbucketService bitbucketService
- private final ILogger logger
- private final def script
- private final IPipelineSteps steps
+ private ILogger logger
+ private def script
+ private IPipelineSteps steps
private IContext context
private boolean notifyNotGreen = true
private boolean ciSkipEnabled = true
@@ -98,7 +98,7 @@ class Pipeline implements Serializable {
if (config.image?.startsWith(wtfEnvBug)) {
config.image = config.image.
replace(wtfEnvBug, "${defaultDockerRegistry}/")
- logger.warn ("Patched image via master env to: ${config.image}")
+ logger.warn("Patched image via master env to: ${config.image}")
}
context.assemble()
@@ -247,7 +247,7 @@ class Pipeline implements Serializable {
}
stages(context)
if (context.commitGitWorkingTree) {
- gitService.commit ([], "system-commit ods, [ci skip]", true)
+ gitService.commit([], "system-commit ods, [ci skip]", true)
gitService.pushRef(context.gitBranch)
}
}
@@ -286,15 +286,33 @@ class Pipeline implements Serializable {
}
logger.debugClocked("${config.componentId}",
"ODS Component Pipeline '${context.componentId}-${context.buildNumber}'\r" +
- "ODS Build Artifacts '${context.componentId}': " +
- "\r${JsonOutput.prettyPrint(JsonOutput.toJson(context.getBuildArtifactURIs()))}"
+ "ODS Build Artifacts '${context.componentId}': " +
+ "\r${JsonOutput.prettyPrint(JsonOutput.toJson(context.getBuildArtifactURIs()))}"
)
+ if (!!!script.env.MULTI_REPO_BUILD) {
+ cleanUp()
+ }
}
}
}
}
}
+ private void cleanUp() {
+ logger.debug('-- SHUTTING DOWN RM (..) --')
+ logger.resetStopwatch()
+ this.script = null
+ this.steps = null
+ this.logger = null
+
+ this.gitService = null
+ this.openShiftService = null
+ this.jenkinsService = null
+ this.bitbucketService = null
+
+ ServiceRegistry.removeInstance()
+ }
+
def setupForMultiRepoBuild(def config) {
logger.info '-> Detected multirepo orchestration pipeline build'
config.localCheckoutEnabled = false
@@ -400,8 +418,8 @@ class Pipeline implements Serializable {
config.annotations = [
script.podAnnotation(
key: 'cluster-autoscaler.kubernetes.io/safe-to-evict', value: 'false'
- )
- ]
+ )
+ ]
}
}
diff --git a/src/org/ods/openshift/OpenShiftResourceMetadata.groovy b/src/org/ods/openshift/OpenShiftResourceMetadata.groovy
index 6923bd6c4..d3e771d85 100644
--- a/src/org/ods/openshift/OpenShiftResourceMetadata.groovy
+++ b/src/org/ods/openshift/OpenShiftResourceMetadata.groovy
@@ -13,9 +13,9 @@ import org.ods.util.IPipelineSteps
* @See
* Guidelines for Labels and Annotations for OpenShift applications
* @See Helm: Labels and Annotations
- *
*/
class OpenShiftResourceMetadata {
+
// Standard roles recognized by OpenShift. Arbitrary roles are supported.
static final ROLE_FRONTEND = 'frontend'
static final ROLE_BACKEND = 'backend'
@@ -173,6 +173,71 @@ class OpenShiftResourceMetadata {
setMetadata(metadata, pauseRollouts, deployments)
}
+ /**
+ * Sanitize all metadata values to make sure they are valid label values.
+ * Valid label values must be 63 characters or less and must be empty
+ * or begin and end with an alphanumeric character ([a-z0-9A-Z])
+ * with dashes (-), underscores (_), dots (.), and alphanumerics between.
+ * If an illegal value is found for an entry that allows modifications, the value will be sanitized as follows:
+ * 1. Any non-alphanumeric characters will be removed from the beginning of the value.
+ * 2. If it's longer than 63 characters, the trailing characters after the 63rd will be removed.
+ * 3. Any non-alphanumeric characters will be removed from the end of the value.
+ * 4. Every remaining illegal character will be replaced with an underscore.
+ *
+ * NOTE: If, after step 1, the value is empty, an exception will be risen
+ * instead of silently assigning an empty value. This situation should be rare, only for non-empty values
+ * consisting only of non-alphanumeric characters.
+ *
+ * If an illegal value is found for an entry that does not allow modifications,
+ * an exception with an informative message will be risen, thus ending the labelling process.
+ *
+ * All values are converted to strings using the toString()
method.
+ *
+ * @param metadata a