如果cntKO > 0,我想让这个阶段失败,但我只能让构建失败。有没有办法让这个阶段失败?
阶段{
stage('Run the Create users based on Env. defined') {
options {
timestamps ()
timeout(time: 6, unit: 'HOURS')
}
steps {
bat 'python batch\\CloudValidation\\Cloudusercreation-csvfile.py %release%'
bat "batch\\CloudValidation\\usercreationoncloudnew.bat %ws% %release% %username% %pwd% %tenant% %POD%"
script{
def pipeline_log1 = currentBuild.rawBuild.getLog(10000);
def result1 = pipeline_log1.find { it.contains('Total Number of KO Users') }
if (result1) {
User_KO = result1.split("Total Number of KO Users:")
cntko = User_KO[1].toInteger()
if (cntko > 0)
{
echo ('Build failed due to' + result1)
**currentBuild.result = 'FAILURE'**
}
}
}
}
}
stage('xyz) {
options {
timestamps ()
timeout(time: 6, unit: 'HOURS')
}
steps {
bat "batch\\CloudValidation\\CreatePvtCollabSpace.bat
}
}
字符串
你能告诉我怎么解决这个问题吗
1条答案
按热度按时间fafcakar1#
如果您已经能够使构建失败,那么只需捕获错误,并且仅使阶段失败,而不会使整个构建失败。为此,请将
steps
Package 在catchError
中:字符串