A common issue is that you are not using the same shell, for example on Ubuntu by default is common to have installed *dash* as the default shell, this causes troubles when you use *bash only features*. A good practice is to set the first line to *"#!/bin/bash" *or *"#!/usr/bin/env bash"* and *set -exuo pipefail *(see https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/) as Amedee said. I am a fan of use pre-commit (https://pre-commit.com/index.html) to validate everything before committing to the repo; pre-commit has a hook to check scripts with shellcheck it is really helpful to avoid stupid mistakes and normalize the way all scripts are made.
El sábado, 6 de marzo de 2021 a las 20:30:10 UTC+1, [email protected] escribió: > Put this as the first line in your shell scripts: > > #!/bin/bash -ex > > -e exits the script immediately if a command exits with a non-zero status. > -x echos the current line in the script when it's executed. > > My best guess is that an error occurs in your script, which is silently > ignored by Bash, but at the end of the script you still have a non-zero > status. > Jenkins checks for that non-zero status and fails. > > > Secondly, verify your scripts with https://www.shellcheck.net/ > You can use ShellCheck online, install it on your local machine, and even > integrate it with most major editors. > Make sure that ShellCheck says "No issues detected!" > > > Without actually seeing the code of your shell scripts, it's at this point > not possible to give you any further debugging tips. > > Hope this helps! > > -- > Amedee > On Friday, March 5, 2021 at 6:12:03 PM UTC+1 [email protected] wrote: > >> I have set up several jenkins jobs that do nothing more than execute bas >> scripts, howevwe The bash scripts run fine and complete with no errors in >> the but jenkins runs and gets errors is there a right way to debug this? > > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f11f6914-a806-4db3-a7f6-ce6fae4d49b8n%40googlegroups.com.
