Bob-the-builder adds a frontend and framework around your scripts. Whilst intended for automating builds, it can be used to assist the running of any UNIX script or program.
I wrote this when I was first learning Go, so the code is a monstrosity.
This should be consider a beta-grade system, with possible security flaws. Do not expose any HTTP endpoints to untrusted clients.
cd
into this repository./build_deb.sh /tmp/btb
.deb
file on the system you want to use it on.sudo systemctl start bob-the-builder.service
.There are two components to every run definition. First, there is a configuration JSON file in the definitions/ folder. Second, there is as folder in base/, which should contain any initial files to be copied into the build folder before the build process commences.
All folders are relative to the working directory of bobthebuilder when invoked.
The JSON config file is simply a json file you whack in /definitions. It should be structured like this:
{
"name": "Build libc",
"icon": "rocket",
"base-folder": "arm base",
"git-src": "https://github.com/twitchyliquid64/bob-the-builder",
"apt-packages-required": [
"build-essentials",
"screen",
"htop"
],
"steps": [
{
"type": "CMD",
"command": "ping",
"args": [
"-c",
"2",
"google.com"
],
"can-fail": true
},
{
"type": "CMD",
"skip-condition": "{{getParameter `include` | eq `true` | not}}",
"command": "git",
"args": [
"log"
]
},
{
"type": "EXEC",
"command": "build.sh",
"can-fail": false
},
{
"type": "S3_UPLOAD",
"bucket": "example.com.my.bucket",
"region": "ap-northwest-2",
"filename": "src/main.c",
"filename-destination": "main.c",
"ACL": "public"
}
],
"params": [
{
"type": "check",
"label": "Update browserify",
"varname": "update",
"default": false
}
]
}
Field Name | Description |
---|---|
name | Name of the run definition. Shows in the UI. |
icon | Icon to show in the UI for that build definition. See a list of icons here |
base-folder | Folder from which files are copied into the build folder during initialisation. This stage occurs after the clean phase and after (if any) the git clone phase. |
git-src | This option should be set if you want to clone a git repository into your build area before running the steps. The passed value is passed to 'git clone |
apt-packages-required | This option should be set if you want to ensure a set of apt-get packages are installed on your system. If you system does not support apt-get, do not set this field in the JSON file. |
params | List of configurable parameters which can be set to customize the build. |
hide-from-log | If this boolean is set, the result of the execution will not be shown on the dashboard. |
notify-on-failure | If this boolean is set and Gmail configuration is present, a email will be sent if the execution fails. |
notify-on-success | If this boolean is set and Gmail configuration is present, a email will be sent if the execution succeeds. |
Type | Description | Parameters |
---|---|---|
CMD | Runs the command with the specified arguments |
|
EXEC | Runs the script specified in 'command' using bash |
|
S3_UPLOAD | Uploads and overwrites the specified file to AWS. AWS information must be populated in the configuration file. |
|
ENV_SET | Allows you to set environment variables for the build system, and any subsequent tasks. |
|
TAR_TO_S3 | Adds the given directories contents and the given files to a tar file, which is then compressed with gzip and streamed to S3. AWS information must be populated in the configuration file. This operation is suitable in low memory environments as the archive and compression routines are streamed on the given data. |
|
SEND_EMAIL | Sends an email using Gmail configuration in config.json . |
|
These fields can be set on any step.
Name | Description |
---|---|
HideFromSteps | This is a boolean field. If set to true, the step will not appear in the UI (top-right) when viewing the definition. |
Conditional | This is a template field which allows you to define an expression, where it will skip evaluation of the step if the expression evaluates len(output) > 0 and output != 'false'. This field can be omitted - in which case the step will always evaluate. |
id | Human-readable identifier for this step. Used with the getOutput <id> template function to get the output of a previously run step. |
You may have noticed that a couple of the parameters in certain step types are 'templates'. This means they support Go's powerful templating system, which you can use to provide values dynamically. For instance, you can make the S3 uploader types prefix your files with todays date, or substitute in a tag name, or anything else that the go text/template engine supports. See here for details.
Additionally, the following functions are available for your templates:
Parameters allow you to define a form so a user can populate information - just before your definitions run.
parameters are setup by adding new structures to the params list (in the JSON file).
All structures must have at minimum the following attributes:
Type | Description |
---|---|
check | adds a checkbox to the workflow. You may also specify a default which must be the string value true or false. |
text | adds a text input to the workflow. You may also specify a placeholder. |
select | adds a dropdown with configurable items. |
branchselect | adds a dropdown which is automatically populated with a list of branches in a remote git repository. |
file | adds a file upload field which will place the contents of the given file in a file on the workspace. |
{
"type": "branchselect",
"label": "Branch",
"varname": "branch",
"default": "master",
"options": {
"branchNamesOnly": true,
"git-url": "https://github.com/twitchyliquid64/bob-the-builder"
}
}
{
"type": "select",
"label": "Master Control",
"varname": "mc",
"items": {
"Hello": "Hi"
},
"default": "Hi",
}
{
"type": "text",
"label": "Name",
"varname": "stuff",
"default": "robert",
}
},
{
"type": "check",
"label": "Backup build artifacts",
"varname": "backup",
"default": true
},
{
"type": "file",
"label": "Upload configuration",
"varname": "file_input_filename",
"filename": "input.json"
}
You can see all the available settings defined in this struct here.