Мне нужно выполнить один этап конвейера Jenkins, когда один файл содержит «ошибки» Я не знаю, как вернуть ошибку из bash в Jenkins
stage('check if file continas error and exit if true') { steps { sh "grep 'error' filetocheck.txt" } } }
ссылка Возможно ли захватить стандартный вывод из команды sh DSL в конвейере
Это сработало для меня,
def runShell(String command){ def responseCode = sh returnStatus: true, script: "${command} &> tmp.txt" def output = readFile(file: "tmp.txt") return (output != "") } pipeline { agent any stages { stage('check shellcheck') { steps { script { if (runShell('grep \'error\' file_to_parse.txt')) { sh "exit 1" } } } } } }