It would be optimal to have a retry checkbox in the sauce-ondemand-plugin with optionally a max retries count so when sauce connects fails it retries, I found that when running multiple tests in parallel cause the tunnel to fail from time to time, always using the same credentials and the same Jenkins slave. I can also recreate in a docker container and with a different Sauce Labs account.
The reason to incorporate this retry mechanism in the plugin is because when the flaky tunnel issue happens the tests fails which is unfortunate.
Without the retry in the plugin there is no option but to stop using it and open the tunnel via shell scripting and implement the retry in our own scripts however this could be useful for other users.
Sample output failure
Starting pre-build for Sauce Labs plugin
Starting Sauce Connect on master node using identifier: "sauceusername-19"
Launching Sauce Connect on ip-********.z.aws
20 Aug 10:57:12 - Sauce Connect 4.3.11, build 1757 2b421bb
20 Aug 10:57:12 - Using CA certificate bundle /etc/ssl/certs/ca-certificates.crt.
20 Aug 10:57:12 - Using CA certificate verify path /etc/ssl/certs.
20 Aug 10:57:12 - Starting up; pid 10545
20 Aug 10:57:12 - Command line arguments: /var/lib/jenkins/sc-4.3.11-linux/bin/sc -u sauceusername -k **** -P 4445 --tunnel-identifier "sauceusername-19"
20 Aug 10:57:12 - Using no proxy for connecting to Sauce Labs REST API.
20 Aug 10:57:12 - Resolving saucelabs.com to 18.104.22.168 took 1 ms.
20 Aug 10:57:12 - Started scproxy on port 40756.
20 Aug 10:57:12 - Please wait for 'you may start your tests' to start your tests.
20 Aug 10:57:12 - Starting secure remote tunnel VM...
20 Aug 10:57:15 - POST https:20 Aug 10:57:15 - Error creating tunnel.
20 Aug 10:57:15 - Sauce Connect could not establish a connection.
20 Aug 10:57:15 - Please check your firewall and proxy settings.
20 Aug 10:57:15 - You can also use sc --doctor to launch Sauce Connect in diagnostic mode.
20 Aug 10:57:15 - Cleaning up.
20 Aug 10:57:18 - Goodbye.