Home > other >  How can I check for SSL error inside the pipeline script
How can I check for SSL error inside the pipeline script

Time:12-16

Jenkins build pipeline job having intermittent SSL error which uses conan build package to build. The reason is conan build folder not refreshing cached SSL.

How can I check for SSL error inside the pipeline script so that I can delete the folder if there's SSL error, so that conan would get the fresh certs from config file when retrying the build.

CodePudding user response:

I don't know specifically what conan does when it gets an SSL error, but I assume either it throws an error in Jenkins or it returns a non-zero exit code.

If it throws a Jenkins error

You can just wrap this in a try step inside a loop:

connected = false

while (!connected) {
  try {
    # Connect to conan here
    connected = true
  } catch(Exception exc) {
    println("Connect successful")
}

You could also catch the relevant exception instead of putting it in a loop. That's probably better but I don't know what your exception is. If you do use a loop like this, put a maximum number of retries on it.

If it returns a non-zero exit code

In this case I guess you're calling it from a bat step, in which case I think you can do:

bat("conan_connect.bat || exit")
  • Related