How do I write a board file from Python, JavaScript, Go, Ruby, PHP or a shell script?
Build the board as an ordinary dictionary, object or struct, turn it into JSON with the language's own JSON library, and write it to a file. There is no SDK to install, because there is nothing to call.
The board all six write
Each example below writes this board to board.json. The Test orb is red because the variable failed is 2. Set it to 0 and the orb is green.
{
"title": "Checkout pipeline",
"tag": "Build # 3082",
"nodes": [
{ "id": "build", "label": "Build", "state": "ok", "value": 3, "unit": "mins", "badge": "Passed" },
{ "id": "test", "label": "Test", "state": "bad", "value": 46, "unit": "mins", "caption": "Last ran", "since": "2026-11-11T16:56:00Z", "badge": "2 tests failed", "after": ["build"] },
{ "id": "deploy", "label": "Deploy", "state": "idle", "badge": "Waiting", "after": ["test"] }
]
}Python
import json
import os
from datetime import datetime, timezone
now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
failed = 2 # however your script learns this
board = {
"title": "Checkout pipeline",
"tag": "Build # 3082",
"nodes": [
{"id": "build", "label": "Build", "state": "ok", "value": 3, "unit": "mins", "badge": "Passed"},
{
"id": "test",
"label": "Test",
"state": "bad" if failed else "ok",
"value": 46,
"unit": "mins",
"caption": "Last ran",
"since": now,
"badge": f"{failed} tests failed" if failed else "Passed",
"after": ["build"],
},
{"id": "deploy", "label": "Deploy", "state": "idle", "badge": "Waiting", "after": ["test"]},
],
}
# Write under another name, then rename, so nothing ever reads half a file.
with open("board.json.tmp", "w") as f:
json.dump(board, f, indent=2)
os.replace("board.json.tmp", "board.json")JavaScript (Node.js)
import { renameSync, writeFileSync } from "node:fs";
const now = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
const failed = 2; // however your script learns this
const board = {
title: "Checkout pipeline",
tag: "Build # 3082",
nodes: [
{ id: "build", label: "Build", state: "ok", value: 3, unit: "mins", badge: "Passed" },
{
id: "test",
label: "Test",
state: failed ? "bad" : "ok",
value: 46,
unit: "mins",
caption: "Last ran",
since: now,
badge: failed ? `${failed} tests failed` : "Passed",
after: ["build"],
},
{ id: "deploy", label: "Deploy", state: "idle", badge: "Waiting", after: ["test"] },
],
};
// Write under another name, then rename, so nothing ever reads half a file.
writeFileSync("board.json.tmp", JSON.stringify(board, null, 2));
renameSync("board.json.tmp", "board.json");Go
package main
import (
"encoding/json"
"fmt"
"os"
"time"
)
type Node struct {
ID string `json:"id"`
Label string `json:"label"`
State string `json:"state"`
Value any `json:"value,omitempty"`
Unit string `json:"unit,omitempty"`
Caption string `json:"caption,omitempty"`
Since string `json:"since,omitempty"`
Badge string `json:"badge,omitempty"`
After []string `json:"after,omitempty"`
}
type Board struct {
Title string `json:"title"`
Tag string `json:"tag"`
Nodes []Node `json:"nodes"`
}
func main() {
now := time.Now().UTC().Format(time.RFC3339)
failed := 2 // however your program learns this
test := Node{ID: "test", Label: "Test", State: "ok", Value: 46, Unit: "mins",
Caption: "Last ran", Since: now, Badge: "Passed", After: []string{"build"}}
if failed > 0 {
test.State = "bad"
test.Badge = fmt.Sprintf("%d tests failed", failed)
}
board := Board{
Title: "Checkout pipeline",
Tag: "Build # 3082",
Nodes: []Node{
{ID: "build", Label: "Build", State: "ok", Value: 3, Unit: "mins", Badge: "Passed"},
test,
{ID: "deploy", Label: "Deploy", State: "idle", Badge: "Waiting", After: []string{"test"}},
},
}
data, err := json.MarshalIndent(board, "", " ")
if err != nil {
panic(err)
}
// Write under another name, then rename, so nothing ever reads half a file.
if err := os.WriteFile("board.json.tmp", data, 0o644); err != nil {
panic(err)
}
if err := os.Rename("board.json.tmp", "board.json"); err != nil {
panic(err)
}
}Ruby
require "json"
require "time"
now = Time.now.utc.iso8601
failed = 2 # however your script learns this
board = {
title: "Checkout pipeline",
tag: "Build # 3082",
nodes: [
{ id: "build", label: "Build", state: "ok", value: 3, unit: "mins", badge: "Passed" },
{
id: "test",
label: "Test",
state: failed.zero? ? "ok" : "bad",
value: 46,
unit: "mins",
caption: "Last ran",
since: now,
badge: failed.zero? ? "Passed" : "#{failed} tests failed",
after: ["build"]
},
{ id: "deploy", label: "Deploy", state: "idle", badge: "Waiting", after: ["test"] }
]
}
# Write under another name, then rename, so nothing ever reads half a file.
File.write("board.json.tmp", JSON.pretty_generate(board))
File.rename("board.json.tmp", "board.json")PHP
<?php
$now = gmdate('Y-m-d\TH:i:s\Z');
$failed = 2; // however your script learns this
$board = [
'title' => 'Checkout pipeline',
'tag' => 'Build # 3082',
'nodes' => [
['id' => 'build', 'label' => 'Build', 'state' => 'ok', 'value' => 3, 'unit' => 'mins', 'badge' => 'Passed'],
[
'id' => 'test',
'label' => 'Test',
'state' => $failed ? 'bad' : 'ok',
'value' => 46,
'unit' => 'mins',
'caption' => 'Last ran',
'since' => $now,
'badge' => $failed ? "$failed tests failed" : 'Passed',
'after' => ['build'],
],
['id' => 'deploy', 'label' => 'Deploy', 'state' => 'idle', 'badge' => 'Waiting', 'after' => ['test']],
],
];
// Write under another name, then rename, so nothing ever reads half a file.
file_put_contents('board.json.tmp', json_encode($board, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
rename('board.json.tmp', 'board.json');Shell, with jq
#!/usr/bin/env bash
set -euo pipefail
now=$(date -u +%Y-%m-%dT%H:%M:%SZ)
failed=2 # however your script learns this
# jq does the quoting, so a stray quote mark in a value cannot break the file.
jq -n --arg now "$now" --argjson failed "$failed" '{
title: "Checkout pipeline",
tag: "Build # 3082",
nodes: [
{id: "build", label: "Build", state: "ok", value: 3, unit: "mins", badge: "Passed"},
{
id: "test",
label: "Test",
state: (if $failed > 0 then "bad" else "ok" end),
value: 46,
unit: "mins",
caption: "Last ran",
since: $now,
badge: (if $failed > 0 then "\($failed) tests failed" else "Passed" end),
after: ["build"]
},
{id: "deploy", label: "Deploy", state: "idle", badge: "Waiting", after: ["test"]}
]
}' > board.json.tmp
# Write under another name, then rename, so nothing ever reads half a file.
mv board.json.tmp board.jsonWhat all of them do
- They use a JSON library. Pasting text together works until a name contains a quote mark. A library gets the quoting right every time.
- They write times in UTC, ending in Z, as in
2026-11-10T21:31:00Z. The board works out "46 mins ago" from that and keeps counting. - They write, then rename. Writing to
board.json.tmpand renaming it means nothing can ever read a half-written file. - They decide the state themselves. FluxGlow never judges whether a number is good or bad. Your code does, and says so with
state.
Other languages
The same three steps work in C#, Java, Rust, PowerShell or anything else with a JSON library: build the structure, serialise it, write the file. The docs list every field, and the editor will tell you if the result is not a valid board.
After the file is written
The board page reads the file over the web, so the last step is to copy it somewhere a browser can reach. Run the script on a timer, or from whatever event changes the answer.
Related questions
-
Where can I host a board file?
Anywhere that serves the file over https, lets other websites read it, and does not cache it for long. A storage bucket, a public GitHub repository or a web server you already run will all do.
-
Does FluxGlow work with GitLab CI, CircleCI, Buildkite or Azure Pipelines?
Yes. FluxGlow has no integrations, so there are none to wait for. Any CI system that can run a shell command at the end of a pipeline can write a board file and upload it.
-
How often does a board update, and can it be faster?
A board reads its file again every 15 seconds. Add &every=5 to the address to read every 5 seconds, which is as fast as it goes. Changes appear on the next read, without the page reloading.