jenkins-lib

Jenkins shared library
git clone https://git.in0rdr.ch/jenkins-lib.git
Log | Files | Refs | README

commit 52ca32c72613679552c329e572c8c1016ffe4103
parent b6ab4deb3ae6f60abdabf34963ddde78ea657b8d
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Tue,  4 Jun 2024 22:50:16 +0200

feat(gitleaks): use try catch

Diffstat:
Mvars/gitleaks.groovy | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/vars/gitleaks.groovy b/vars/gitleaks.groovy @@ -10,15 +10,19 @@ def call() { stages { stage('scan') { - steps { - script { - ret = sh returnStatus: true, script: ''' - gitleaks detect \ - --verbose --no-color --no-banner \ - --report-path gitleaks-report.json \ + script { + try { + sh returnStatus: true, script: ''' + gitleaks detect \ + --verbose --no-color --no-banner \ + --report-path gitleaks-report.json \ ''' - if (ret != 0) { + } catch (err) { + def report = readJSON file: 'gitleaks-report.json' + if (!report.isEmpty) { unstable(message: "Secrets detected in ${BUILD_URL}") + } else { + error(message: $err) } } }