Home > OS >  Jenkins execute command only if previous one failed
Jenkins execute command only if previous one failed

Time:11-25

I have the following problem. I have a command that unfortunately only works from time to time in powershell. Sometimes an error comes sometimes it runs through.

Now I am looking for an option in the declarative Jenkins pipeline to execute a step, if this step fails it should execute another command.

However, if the first command runs through, skip the second command, because it is then no longer necessary.

Unfortunately I don't know at all how to implement this.

I have thought about catch error. I have thought about if else .

CodePudding user response:

Maybe what you need it's already resolved here. I've been working with try/catch because I had same issues of unstable executions and works like a charm. Try-catch block in Jenkins pipeline script

  • Related