From d1afd4e4c5ba06dceafa1bd964dae4f866aa86da Mon Sep 17 00:00:00 2001 From: "QTSEL\\PSQ" Date: Wed, 16 Apr 2025 17:34:44 +0200 Subject: [PATCH 1/5] chore(QTDI-1475): Update Jenkinsfile to adjust build discarder settings --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ff88d57ab3798..1d2963f0fbe0c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -103,7 +103,9 @@ pipeline { } options { - buildDiscarder(logRotator(artifactNumToKeepStr: '10', numToKeepStr: branch_name == 'master' ? '15' : '10')) + buildDiscarder(logRotator(artifactNumToKeepStr: '5', + numToKeepStr: '5', + daysToKeepStr: '10')) timeout(time: 180, unit: 'MINUTES') skipStagesAfterUnstable() } From 69dc66d651af44a67a7c6a3ad63940f4040a14a6 Mon Sep 17 00:00:00 2001 From: "QTSEL\\PSQ" Date: Wed, 16 Apr 2025 17:55:31 +0200 Subject: [PATCH 2/5] chore(QTDI-1475): Update Jenkinsfile to log Maven build and deploy output and filter for warnings and errors --- Jenkinsfile | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1d2963f0fbe0c..1b31cc73d12ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,6 +66,9 @@ final String buildTimestamp = String.format('-%tY%&1 | tee $BUILD_LOG_FILE | grep -E 'WARN|ERROR' + """.stripIndent() } } post { @@ -443,7 +448,8 @@ pipeline { set -xe bash mvn deploy $deployOptions \ $extraBuildParams \ - --settings .jenkins/settings.xml + --settings .jenkins/settings.xml \ + 2>&1 | tee $DEPLOY_LOG_FILE | grep -E 'WARN|ERROR' """.stripIndent() } } From e6700fd814803852f51768ba4e911c4e1177b981 Mon Sep 17 00:00:00 2001 From: "QTSEL\\PSQ" Date: Tue, 22 Apr 2025 12:09:55 +0200 Subject: [PATCH 3/5] chore(Jenkinsfile): Refactor log file handling and archive the maven logs files --- Jenkinsfile | 65 ++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1b31cc73d12ca..fc556abca435a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,8 +66,8 @@ final String buildTimestamp = String.format('-%tY%&1 | tee $BUILD_LOG_FILE | grep -E 'WARN|ERROR' - """.stripIndent() + """.stripIndent() } } post { always { + archiveArtifacts artifacts: "${"**/$BUILD_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false recordIssues( enabledForFailure: false, tools: [ @@ -431,6 +432,7 @@ pipeline { } } } + stage('Maven deploy') { when { anyOf { @@ -459,8 +461,7 @@ pipeline { if (devBranch_mavenDeploy) { repo = ['artifacts-zl.talend.com', 'https://artifacts-zl.talend.com/nexus/content/repositories/snapshots/org/talend/sdk/component'] - } - else { + } else { repo = ['oss.sonatype.org', 'https://oss.sonatype.org/content/repositories/snapshots/org/talend/sdk/component/'] } @@ -468,7 +469,13 @@ pipeline { jenkinsJobTools.job_description_append("Maven artefact deployed as ${finalVersion} on [${repo[0]}](${repo[1]}) ") } } + post { + always { + archiveArtifacts artifacts: "${"**/$DEPLOY_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false + } + } } + stage('Docker build/push') { when { anyOf { @@ -484,13 +491,11 @@ pipeline { if (isStdBranch) { // Build and push all images jenkinsJobTools.job_description_append("Docker images deployed: component-server, component-starter-server and remote-engine-customizer ") - } - else { + } else { String image_list if (params.DOCKER_CHOICE == 'All') { images_options = 'false' - } - else { + } else { images_options = 'false ' + params.DOCKER_CHOICE } @@ -498,25 +503,22 @@ pipeline { jenkinsJobTools.job_description_append("All docker images deployed ") jenkinsJobTools.job_description_append("As ${finalVersion}${buildTimestamp} on " + - "[artifactory.datapwn.com]" + - "($artifactoryAddr/$artifactoryPath) ") + "[artifactory.datapwn.com]" + + "($artifactoryAddr/$artifactoryPath) ") jenkinsJobTools.job_description_append("docker pull $artifactoryAddr/$artifactoryPath" + - "/component-server:${finalVersion}${buildTimestamp} ") + "/component-server:${finalVersion}${buildTimestamp} ") jenkinsJobTools.job_description_append("docker pull $artifactoryAddr/$artifactoryPath" + - "/component-starter-server:${finalVersion}${buildTimestamp} ") + "/component-starter-server:${finalVersion}${buildTimestamp} ") jenkinsJobTools.job_description_append("docker pull $artifactoryAddr/$artifactoryPath" + - "/remote-engine-customize:${finalVersion}${buildTimestamp} ") + "/remote-engine-customize:${finalVersion}${buildTimestamp} ") - } - else { + } else { jenkinsJobTools.job_description_append("Docker images deployed: $params.DOCKER_CHOICE ") jenkinsJobTools.job_description_append("As ${finalVersion}${buildTimestamp} on " + - "[artifactory.datapwn.com]($artifactoryAddr/$artifactoryPath) ") + "[artifactory.datapwn.com]($artifactoryAddr/$artifactoryPath) ") jenkinsJobTools.job_description_append("docker pull $artifactoryAddr/$artifactoryPath/$params.DOCKER_CHOICE:" + - "${finalVersion}${buildTimestamp} ") - + "${finalVersion}${buildTimestamp} ") } - } // Build and push specific image @@ -526,10 +528,10 @@ pipeline { ${images_options} """ } - } } } + stage('Documentation') { when { expression { @@ -551,6 +553,7 @@ pipeline { } } } + stage('OSS security analysis') { when { anyOf { @@ -581,6 +584,7 @@ pipeline { } } } + stage('Deps report') { when { anyOf { @@ -620,6 +624,7 @@ pipeline { } } } + stage('Sonar') { when { expression { (params.Action != 'RELEASE') && !params.DISABLE_SONAR } @@ -640,8 +645,7 @@ pipeline { '${pull_request_id}' \ ${extraBuildParams} """ - } - else { + } else { echo 'Run analysis for branch' sh """ bash .jenkins/scripts/mvn_sonar_branch.sh \ @@ -653,6 +657,7 @@ pipeline { } } } + stage('Release') { when { allOf { @@ -791,12 +796,10 @@ private static String add_qualifier_to_version(String version, String ticket, St if (user_qualifier.contains("DEFAULT")) { if (version.contains("-SNAPSHOT")) { new_version = version.replace("-SNAPSHOT", "-$ticket-SNAPSHOT" as String) - } - else { + } else { new_version = "$version-$ticket".toString() } - } - else { + } else { new_version = version.replace("-SNAPSHOT", "-$user_qualifier-SNAPSHOT" as String) } return new_version From e728bb91fb22eaf18047bfec33471016103191c7 Mon Sep 17 00:00:00 2001 From: "QTSEL\\PSQ" Date: Tue, 22 Apr 2025 17:23:56 +0200 Subject: [PATCH 4/5] Refactor Trivy build --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index fc556abca435a..92b5c55ea5be6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -418,6 +418,7 @@ pipeline { } post { always { + jenkinsJobTools.job_description_append("You will find full build logs in artefacts as $BUILD_LOG_FILE") archiveArtifacts artifacts: "${"**/$BUILD_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false recordIssues( enabledForFailure: false, @@ -471,6 +472,7 @@ pipeline { } post { always { + jenkinsJobTools.job_description_append("You will find full deploy logs in artefacts as $DEPLOY_LOG_FILE") archiveArtifacts artifacts: "${"**/$DEPLOY_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false } } From 6017e93c32b5363e474453730194ac1b183c091f Mon Sep 17 00:00:00 2001 From: "QTSEL\\PSQ" Date: Tue, 22 Apr 2025 17:33:07 +0200 Subject: [PATCH 5/5] chore(Jenkinsfile): Enhance log filtering and structure for build and deploy processes --- Jenkinsfile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 92b5c55ea5be6..6395de8c740d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,6 +68,7 @@ final String artifactoryPath = "tlnd-docker-dev/talend/common/tacokit" final String BUILD_LOG_FILE = "build.log" final String DEPLOY_LOG_FILE = "deploy.log" +final String MAVEN_GREP_FILTER = "WARN|ERROR|-----------[| :: |-------<|\\[[0-9]+/[0-9]+\\]|\\[INFO\\] Reactor|\\[INFO\\] BUILD" // Job variables declaration String branch_user @@ -412,14 +413,16 @@ pipeline { mvn clean install $BUILD_ARGS \ $extraBuildParams \ --settings .jenkins/settings.xml \ - 2>&1 | tee $BUILD_LOG_FILE | grep -E 'WARN|ERROR' + 2>&1 | tee $BUILD_LOG_FILE | grep -E '$MAVEN_GREP_FILTER' """.stripIndent() } } post { always { - jenkinsJobTools.job_description_append("You will find full build logs in artefacts as $BUILD_LOG_FILE") - archiveArtifacts artifacts: "${"**/$BUILD_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false + script { + jenkinsJobTools.job_description_append("You will find full build logs in artefacts as $BUILD_LOG_FILE") + archiveArtifacts artifacts: "${"**/$BUILD_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false + } recordIssues( enabledForFailure: false, tools: [ @@ -452,7 +455,7 @@ pipeline { bash mvn deploy $deployOptions \ $extraBuildParams \ --settings .jenkins/settings.xml \ - 2>&1 | tee $DEPLOY_LOG_FILE | grep -E 'WARN|ERROR' + 2>&1 | tee $DEPLOY_LOG_FILE | grep -E '$MAVEN_GREP_FILTER' """.stripIndent() } } @@ -472,8 +475,10 @@ pipeline { } post { always { - jenkinsJobTools.job_description_append("You will find full deploy logs in artefacts as $DEPLOY_LOG_FILE") - archiveArtifacts artifacts: "${"**/$DEPLOY_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false + script { + jenkinsJobTools.job_description_append("You will find full deploy logs in artefacts as $DEPLOY_LOG_FILE") + archiveArtifacts artifacts: "${"**/$DEPLOY_LOG_FILE"}", allowEmptyArchive: false, onlyIfSuccessful: false + } } } }