`!include-raw-escape` will insert extra curly braces, in such cases its
recommended to use `!include-raw`.
+.. _shell-scripts:
+
+Shell scripts
+=============
+
+When developing shell scripts for JJB we recommend to create shell scripts as
+a separate file instead of inlining in YAML. This way we can ensure that the
+ShellCheck linter can catch potential issues with the scripts.
+
+When writing the script itself, we recommend to redeclare all expected
+inputs at the top of the file using lowercase variable names before setting
+``set -u`` after the inputs section. This ensures that all variables the
+script expects are at the top of the file which is useful for others to review
+and debug the script at a later stage. The ``set -u`` configuration before the
+start of the script code ensures that we catch any of these undeclared
+variables at the top of the file.
+
+Example:
+
+.. code-block:: bash
+
+ #!/bin/bash
+
+ # Inputs
+ tox_dir="${TOX_DIR:-$WORKSPACE}"
+ tox_envs="${TOX_ENVS:-}"
+
+ # Script start
+ set -eux -o pipefail
+
+ # ... script code goes here
+
Usage of config-file-provider
=============================
- shell: !include-raw:
- ../shell/logs-get-credentials.sh
- shell: !include-raw:
- - ../shell/lftools-install.sh
- ../shell/logs-deploy.sh
- shell: !include-raw:
- ../shell/logs-clear-credentials.sh
3 basic steps:
1. Provide credentials via config-file-provider
-2. Run the build scripts in this case lftools-install.sh and logs-deploy.sh
+2. Run logs-deploy.sh
3. Remove credentials provided by config-file-provider
.. _preserve-variable-refs:
If we do not declare a default in the :ref:`job-template <job-template>` then
JJB will fallback to checking the "defaults configuration".
-This means that the precendence of defaults is as follows:
+This means that the precedence of defaults is as follows:
1. User-provided
2. Job Template
global-jjb should not provide job-group definitions and leave it up to users of
global-jjb to create their own as a job-group as a variable defined in a job
-group the highest precendence. Global JJB should strive to be purely a
+group the highest precedence. Global JJB should strive to be purely a
job-template and macro library for downstream consumers.
Final thoughts