Mitto CMD job - debugging

Because mitto CMD jobs don’t log the output of the command or script, outputting to a txt file is extremely useful.

For example if you wanted to pull a git repo with the command:
cd /var/mitto/data/git_repository && git pull
You’d want to know what was pulled from git, or if there was any errors.

To print the output and/or the error to a txt file, the same command would look like this:
cd /var/mitto/data/git_repository && git pull > /var/mitto/data/pull_output.txt 2>&1

To load this file in the browser using Mitto’s API:
https://{mitto_url}/api/file/pull_output.txt

> overwrites any existing data in pull_output.txt. To append to the file instead use >>

New in Mitto 2.9 is support for multiple commands in a CMD job.

In terms of debugging, this means you can now log output to a file using: exec 1>/var/mitto/data/log-output.txt 2>&1

Just add this line to the top of any command job. The following shows its usage in a job config:

{
  shell: true
  cmd:
    '''
    exec 1>/var/mitto/data/log-env.txt 2>&1
    env
    '''
  exec: false
  timeout: null
  cmd_env: {
  }
}