Skip to content

Job using Bash runtime

The following example shows how to create a job using the Bash runtime agents.

Check

If using no-auth mode you need to ensure that you return 0 for successful execution and 1 for failure.

expected_value='test123!'

if [[ -n "${requestParam:-}" ]]; then

    # Return 1 on no match
    if [[ "$requestParam" != "$expected_value" ]]; then
        return 1
    fi
else
    # Return 1 if request parameter is not set
    echo "Request parameter is not set." >&2
    return 1
fi

# Return 0 on match
return 0

Do

The script can produce any result you want, the output will be returned to the caller using stdout.

echo "Success"

Set Bash mode

All these options will automatically result in the Job being stopped.

# set -euo pipefail  
set -e            # exit immediately if any command fails
set -u            # treat unset variables as errors
set -o pipefail   # a pipe fails if any command in it fails, not just the last

Logging

If you worker is set to keep Job run directories then you can log the output of your script with the following.

# Trace script exection to a log file
# Default location: /var/lib/reacks-worker/run/JOBID
exec 2>> job.log 
set -x