Converting scripts to tasks
To convert an existing script to a task, you can either write a task that wraps the script or you can add logic in your script to check for parameters in environment variables.
If the script is already installed on the target nodes, you can write a task that wraps the script. In the task, read the script arguments as task parameters and call the script, passing the parameters as the arguments.
If the script isn't installed or you want to make it into a cohesive task
so that you can manage its version with code management tools, add code to your script to
check for the environment variables, prefixed with PT_
, and read them instead of arguments.
Given a script that accepts positional arguments on the command line:
version=$1 [ -z "$version" ] && echo "Must specify a version to deploy && exit 1 if [ -z "$2" ]; then filename=$2 else filename=~/myfile fi
To convert the script into a task, replace this logic with task variables:
version=$PT_version #no need to validate if we use metadata if [ -z "$PT_filename" ]; then filename=$PT_filename else filename=~/myfile fi