Hot answers tagged

8

You can also use error to exit the current stage, then you don't have to consider the current stage hierarchy and similar stuff: def autoCancelled = false try { stage('checkout') { ... if (your condition) { autoCancelled = true error('Aborting the build.') } } } catch (e) { if (autoCancelled) { currentBuild.result = '...


4

def suiteRunId = UUID.randomUUID().toString() worked at the top of the Jenkinsfile. Thanks all for your answers.


3

The block needs to be resolved for each stage, otherwise you could not use stage dependent methods in the block, so there would need to be some check on what methods to use and what to not use, it would lead to even more problems. Further each stage can be executed on different node, so the code needs to re-resolve it. Otherwise it would just behave ...


2

This question seems similar to another on StackOverflow, but seems to be a close, but not exact duplicate of https://stackoverflow.com/questions/37018509/jenkinsfile-build-log To quote those : if you just want to check, that your log contains string myTestString you can just call manager.logContains('.myTestString.') If you want to get some ...


1

No, Jenkins file is not created at execution. Actually Jenkins file is a suite of all steps or activity which you want to build as a job or a groovy code. Jenkins file come from code repository, if you added file in your project. Below is a Jenkins file example: pipeline { agent any stages { stage('Build') { steps { ...


Only top voted, non community-wiki answers of a minimum length are eligible