Skip to content

Structure of .githubTaskManager.json

AV edited this page Mar 13, 2018 · 6 revisions

The .githubTaskManager.json file is used to control the automation that is executed in response to a given github event.

Each eventType targetted is a top level member of the json file, and must map to a supported github eventType.

EventType config contains:

  1. agentGroup : String(optional) used to target a group of agents to handle events for this repo/event type.
  2. tasks : Array of task definitions to be executed. This array is run in parallel.
{
    "pull_request": {
        "agentGroup": "GTM",
        "tasks": [ 
            <array of task objects> 
        ]
    }
}

Each task definition contains:

  1. executor : String name of a supported executor. eg. 'Jenkins' or 'Docker'
  2. context : String short unique description of task.
  3. options : Object containing config passed to executor function. The structure of the options is executor specific. (see below)
  4. disabled : Boolean(optional) disable this task and its subtasks temporarily?
  5. tasks : Array(optional) of subtasks to be executed in parallel when parent task is completed. Same structure as parent.

Executor options

Here are the supported 'options' for each executor currently supported.

Jenkins options

  1. jobName : String name of Jenkins job to execute in configured Jenkins environment.
  2. parameters : Object containing key:value pairs to be passed to Jenkins job. Note that templated parameters are available in form @##KEY### (TODO supported keys).
{
    "executor": "Jenkins",
    "context": "run e2e tests",
    "options": {
        "jobName": "EXECUTE_AUTOMATED_TESTS",
        "parameters": {
            "TAGS": "['@project-tag', '@##GHREPONAME']",
            "ENVIRONMENT": "test1"
        }
    }
}

Docker options

  1. image : String name of image to pull from registry and run. eg. 'alpine:latest'
  2. command : Array of Strings making up command to execute in container.
  3. env: Dictionary object to be passed to container as environment variables. Token replacement supported.
{        
    "executor": "Docker",
    "context": "run ls in latest alpine",
    "options": {
        "image": "alpine:latest",
        "command": "/bin/ls -ltra /bin/ls"
	"env": {
            "MYVAR": "MYVAL",
            "MYVAR2": "MYVAL2"
        }
    }
} 

DockerSonar options

This is a subclass of the Docker executor. Please ensure that relevant GTM_SONAR_* environment vars are configured for agents.

Pass in BUILD_TYPE as one of: maven, gradle, nodejs. The remaining options are defined in the executor and are context sensitive. You can override any options here.

{
    "executor": "DockerSonar",
    "context": "Scan PR",
    "options": {
        "env": {
            "BUILD_TYPE": "nodejs"
        }
    }
} 

LaunchDarkly options

Requires a LaunchDarkly (https://launchdarkly.com) account, and env var LAUNCHDARKLY_API_TOKEN configured for agents.

  1. project : The LaunchDarkly project name.
  2. environment : The LaunchDarkly environment name.
  3. flags : The LaunchDarkly flags to toggle on/off in given environment. (true=on, false=off)
{
    "executor": "LaunchDarkly",
    "context": "Set FeatureFlags",
    "options": {
        "project": "myProject",
        "environment": "dev",
        "flags": {
            "testFlagOne": true,
            "testFlagTwo": false
        }
    }
}

TeamCity options

  1. jobName : String name of Jenkins job to execute in configured Jenkins environment.
  2. parameters : Object containing key:value pairs to be passed to Jenkins job.
{
    "executor": "TeamCity",
    "context": "run e2e tests",
    "options": {
        "jobName": "EXECUTE_AUTOMATED_TESTS",
        "parameters": {
            "TAGS": "['@project-tag', '@##GHREPONAME']",
            "ENVIRONMENT": "test1"
        }
    }
}

Http options

  1. har : object in HAR format describing request to make. Refer to http://www.softwareishard.com/blog/har-12-spec/#request
  2. validator : Object(optional) type of validator used to check the response object and determine pass/fail. Currently only supports validator.type="bodyJson".
{
    "executor": "Http",
    "context": "check response host header"
    "options": {
        "har": {
            "url": "http://expected.hostname.com.au",
            "method": "GET",
            "headers": [
                {
                    "name": "accept",
                    "value": application/json"
                }   
            ]   
        },
        "validator": {
	        "type": "bodyJson",
	        "objectCheckRef": "headers.Host",
	        "objectCheckRef": "expected.hostname.com.au"
        }
    }
}