From 6ab627f6bb619022880267d141188137b924a189 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 16 Apr 2024 11:08:17 +0200 Subject: [PATCH 1/2] fix(jenkins): Consistenly delete output directories before running tools Delete the directories that get archived by Jenkins after the step has run to avoid any left-over artifacts to get archived for the wrong run (as has happened with the reporter). Signed-off-by: Sebastian Schuberth --- integrations/jenkins/Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/integrations/jenkins/Jenkinsfile b/integrations/jenkins/Jenkinsfile index e05f0dd910f31..4e38693d95894 100644 --- a/integrations/jenkins/Jenkinsfile +++ b/integrations/jenkins/Jenkinsfile @@ -568,7 +568,7 @@ pipeline { /opt/ort/bin/set_gradle_proxy.sh - rm -fr out/results + rm -fr out/results/analyzer /opt/ort/bin/ort $ORT_OPTIONS analyze -i "$PROJECT_DIR/source/$ANALYZER_INPUT_PATH" -o out/results/analyzer -l JENKINS_BUILD_URL=$BUILD_URL '''.stripIndent().trim() @@ -690,6 +690,7 @@ pipeline { echo "default login $LOGIN password $PASSWORD" > $HOME/.netrc + rm -fr out/results/scanner /opt/ort/bin/ort $ORT_OPTIONS scan \ -i out/results/current-result.yml \ -o out/results/scanner \ @@ -778,6 +779,7 @@ pipeline { ADVISOR_OPTIONS="-a OSV,VulnerableCode" + rm -fr out/results/advisor /opt/ort/bin/ort $ORT_OPTIONS advise $ADVISOR_OPTIONS -i out/results/current-result.yml -o out/results/advisor '''.stripIndent().trim() @@ -848,6 +850,7 @@ pipeline { RULES_OPTIONS="$RULES_OPTIONS --rules-file $ORT_CONFIG_DIR/evaluator.rules.kts" fi + rm -fr out/results/evaluator /opt/ort/bin/ort $ORT_OPTIONS evaluate -i out/results/current-result.yml $RULES_OPTIONS -o out/results/evaluator '''.stripIndent().trim() @@ -914,6 +917,7 @@ pipeline { REPORT_FORMATS_OPTIONS_OPTION="-O $REPORT_FORMATS_OPTIONS" fi + rm -fr out/results/reporter /opt/ort/bin/ort $ORT_OPTIONS report \ -i out/results/current-result.yml \ -o out/results/reporter \ From a6a852f371912bb2b63da75441346d1aaae88ac1 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 16 Apr 2024 11:13:34 +0200 Subject: [PATCH 2/2] fix(jenkins): Quote path-related variables in more places Guard against spaces in paths by quoting respective variables. Signed-off-by: Sebastian Schuberth --- integrations/jenkins/Jenkinsfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/integrations/jenkins/Jenkinsfile b/integrations/jenkins/Jenkinsfile index 4e38693d95894..8c613bbaa2656 100644 --- a/integrations/jenkins/Jenkinsfile +++ b/integrations/jenkins/Jenkinsfile @@ -402,12 +402,12 @@ pipeline { VCS_REVISION_OPTION="--vcs-revision $PROJECT_VCS_REVISION" fi - echo "default login $LOGIN password $PASSWORD" > $HOME/.netrc + echo "default login $LOGIN password $PASSWORD" > "$HOME/.netrc" rm -fr "$PROJECT_DIR" /opt/ort/bin/ort $ORT_OPTIONS download --project-url $PROJECT_VCS_URL $VCS_REVISION_OPTION -o "$PROJECT_DIR/source" - rm -f $HOME/.netrc + rm -f "$HOME/.netrc" '''.stripIndent().trim() } } @@ -449,12 +449,12 @@ pipeline { VCS_REVISION_OPTION="--vcs-revision $ORT_CONFIG_VCS_REVISION" fi - echo "default login $LOGIN password $PASSWORD" > $HOME/.netrc + echo "default login $LOGIN password $PASSWORD" > "$HOME/.netrc" - rm -fr $ORT_DATA_DIR/config - /opt/ort/bin/ort $ORT_OPTIONS download --project-url $ORT_CONFIG_VCS_URL $VCS_REVISION_OPTION -o $ORT_DATA_DIR/config + rm -fr "$ORT_DATA_DIR/config" + /opt/ort/bin/ort $ORT_OPTIONS download --project-url $ORT_CONFIG_VCS_URL $VCS_REVISION_OPTION -o "$ORT_DATA_DIR/config" - rm -f $HOME/.netrc + rm -f "$HOME/.netrc" '''.stripIndent().trim() } @@ -467,7 +467,7 @@ pipeline { echo "Not creating '$ORT_CONFIG_DIR/config.yml' as it already exists." else echo "Creating '$ORT_CONFIG_DIR/config.yml' template for job parameters." - cat >$ORT_CONFIG_DIR/config.yml <"$ORT_CONFIG_DIR/config.yml" < $HOME/.netrc + echo "default login $LOGIN password $PASSWORD" > "$HOME/.netrc" rm -fr out/results/scanner /opt/ort/bin/ort $ORT_OPTIONS scan \ @@ -698,7 +698,7 @@ pipeline { $PROJECT_SCANNERS_OPTION \ $SCANNERS_OPTION - rm -f $HOME/.netrc + rm -f "$HOME/.netrc" fi '''.stripIndent().trim()