- Get Started
- Functionality
- Learning
- Extension
- Dev Tooling
- APIs
- Releases
Changed on:
9 Nov 2026
`latest`, `22.x`) make an old green build impossible to reproduce.Upgrade the CLI deliberately, in its own change, and re-run the pipeline. The error wrapper below matches CLI log messages, so re-check it after every upgrade.`module install -r <ref>`) authenticate as that retailer's user, so you must add every retailer to the profile before installing.CI runners are discarded after each run, so recreate the profile from scratch every time under a fixed name such as `cicd`. Never restore one from a cache.`ACMEDEV`, `ACMEUAT`, ...). The same pipeline then targets a different account simply by running under a different deployment.| Variable | Scope |
`FLUENT_ACCOUNT_ID`, `FLUENT_BASE_URL` | Account |
`FLUENT_USERNAME`, `FLUENT_PASSWORD`, `FLUENT_CLIENT_SECRET` | Account admin (secured) |
`FLUENT_RETAILERS` | Retailer refs for this run, space- or comma-separated |
`FLUENT_RETAILER_<REF>_ID` | Per retailer |
`FLUENT_RETAILER_<REF>_USERNAME`, `FLUENT_RETAILER_<REF>_PASSWORD` | Per retailer (secured) |
`$NAME` reference. That happens when a step is missing its `deployment:` and therefore never received the variables, and the CLI otherwise fails much later with an opaque 401. The script reports variable names only and never prints values.Extend the per-retailer loop to confirm that every reference module named in `cicd/configs/` appears in `fluent module list` output, so a missing base module is caught before anything is installed.`{ errors: [Array] }`. Preloading a small Node script raises `util.inspect` limits so the log shows the actual error entries. It only changes how errors are printed, never what the CLI does.1#!/bin/bash
2# cicd/prepare.sh — install the tooling every pipeline step needs: Node, zip, Fluent CLI.
3set -euo pipefail
4
5NODE_MAJOR="${NODE_MAJOR:-22}"
6NODE_VERSION="${NODE_VERSION:-22.18.0}"
7NODE_DEB_REVISION="${NODE_DEB_REVISION:-1nodesource1}"
8FLUENT_CLI_VERSION="${FLUENT_CLI_VERSION:-<pinned version>}"
9FLUENT_CLI_URL="https://downloads.fluentcommerce.com/v1.0.0/fluent-cli/release/$FLUENT_CLI_VERSION"
10
11curl -fsSL "https://deb.nodesource.com/setup_$NODE_MAJOR.x" | bash -
12apt-get install -y "nodejs=$NODE_VERSION-$NODE_DEB_REVISION" zip
13
14[ "$(node --version)" = "v$NODE_VERSION" ] || { echo "Unexpected Node $(node --version)" >&2; exit 1; }
15
16npm install -g "$FLUENT_CLI_URL"
17echo "fluent-cli $(fluent --version)"1#!/bin/bash
2# Creates the CLI profile the install steps run against and verifies each retailer.
3# Usage: cicd/profile.sh <modules-dir>
4set -euo pipefail
5
6PROFILE="${FLUENT_PROFILE:-cicd}"
7REQUIRED_ACCOUNT_VARS="FLUENT_ACCOUNT_ID FLUENT_USERNAME FLUENT_PASSWORD FLUENT_CLIENT_SECRET FLUENT_BASE_URL"
8: "${FLUENT_RETAILERS:?FLUENT_RETAILERS is required}"
9RETAILER_REFS=$(echo "$FLUENT_RETAILERS" | tr ',' ' ' | tr -s ' ')
10
11fail() { echo "Error: $*" >&2; exit 1; }
12
13# Retailer refs may contain characters that are invalid in variable names.
14retailer_var() { echo "FLUENT_RETAILER_$(printf '%s' "$1" | tr '[:lower:]' '[:upper:]' | tr -c 'A-Z0-9' '_')_$2"; }
15retailer_value() { local v; v=$(retailer_var "$1" "$2"); echo "${!v:-}"; }
16
17check_env() {
18 local missing="" unexpanded="" var ref field
19 for var in $REQUIRED_ACCOUNT_VARS; do
20 [ -n "${!var:-}" ] || { missing="$missing $var"; continue; }
21 case "${!var}" in '$'*) unexpanded="$unexpanded $var" ;; esac
22 done
23 for ref in $RETAILER_REFS; do
24 for field in ID USERNAME PASSWORD; do
25 var=$(retailer_var "$ref" "$field")
26 [ -n "${!var:-}" ] || { missing="$missing $var"; continue; }
27 case "${!var}" in '$'*) unexpanded="$unexpanded $var" ;; esac
28 done
29 done
30 [ -z "$missing" ] || fail "missing variable(s):$missing"
31 # Names only: a real secret may legitimately start with '$'.
32 [ -z "$unexpanded" ] || fail "variable(s) hold an unexpanded reference, not a value:$unexpanded
33 Check the step has the matching 'deployment:'."
34}
35
36check_env
37rm -rf "$HOME/.fluentcommerce/$PROFILE"
38
39fluent profile create "$PROFILE" \
40 --id "$FLUENT_ACCOUNT_ID" \
41 --username "$FLUENT_USERNAME" \
42 --password "$FLUENT_PASSWORD" \
43 --client-secret "$FLUENT_CLIENT_SECRET" \
44 --base-url "$FLUENT_BASE_URL" ||
45 fail "could not create profile; a 401 on /user/<username>/grant means the account admin credentials were rejected"
46
47for ref in $RETAILER_REFS; do
48 fluent profile update "$PROFILE" --retailer "$ref" \
49 --id "$(retailer_value "$ref" ID)" \
50 --username "$(retailer_value "$ref" USERNAME)" \
51 --password "$(retailer_value "$ref" PASSWORD)" ||
52 fail "could not add retailer '$ref'"
53 # A retailer-scoped read fails if the retailer is missing or its credentials are wrong.
54 fluent setting list --profile "$PROFILE" --retailer "$ref" --first 1 --json >/dev/null 2>&1 ||
55 fail "retailer '$ref' is not reachable"
56done
57
58echo "Profile '$PROFILE' ready with retailer(s): $RETAILER_REFS"1#!/usr/bin/env bash
2# fluent-cli.sh — run the Fluent CLI and fail on errors it logs but does not exit on.
3# Usage: ./fluent-cli.sh module install . -p cicd -r ACME
4# STRICT=1 (default) also fails on any bare "error:" line, which is the only way to
5# catch GraphQL errors[].message as they carry no other prefix.
6set -uo pipefail
7
8FAIL_PATTERNS=(
9 'Got 404, SKIPPING:'
10 'Validation errors:'
11 'Invalid permissions, aborting:'
12 'Workflow update FAILED'
13 'Unsuccessful response:'
14 'Got status [0-9]+ \('
15 'Unspecific error:'
16 'Error occurred uploading File'
17 'Error occurred uploading plugin:'
18 'Batch did not complete successfully:'
19 'Error response \(status'
20 'bundle not verified\.'
21 'not uploaded\.'
22 'Error during installation\. Status:'
23 'Could not run the GraphQL mutation'
24 'Could not activate the '
25 'Setting could not be created:'
26 'Unable to determine Context for Setting:'
27 'Unrecognised file extension for file:'
28 '! Failed to install module'
29 '! Failed: +[0-9]+'
30)
31BENIGN_PATTERNS=('Request timed out or connection was reset')
32
33log_dir="${FLUENT_LOG_DIR:-.}"
34mkdir -p "$log_dir"
35base="$log_dir/fluent-${1}${2:+-$2}"
36LOG="$base.log"; n=2
37while [ -e "$LOG" ]; do LOG="$base-$n.log"; n=$((n + 1)); done
38
39# Readable nested error payloads instead of "{ errors: [Array] }".
40preload="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/cicd/node-deep-inspect.cjs"
41[ -e "$preload" ] && export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--require $preload"
42
43fluent "$@" 2>&1 | tee "$LOG"
44rc=${PIPESTATUS[0]}
45
46patterns=$(printf '%s\n' "${FAIL_PATTERNS[@]}")
47[ "${STRICT:-1}" = "1" ] && patterns="$patterns"$'\n''^error: '
48
49matches=$(sed -E $'s/\x1b\\[[0-9;]*m//g' "$LOG" |
50 grep -nE -f <(echo "$patterns") |
51 grep -vE -f <(printf '%s\n' "${BENIGN_PATTERNS[@]}") || true)
52
53if [ -n "$matches" ]; then
54 echo "FAIL: CLI reported error(s) in $LOG (exit code $rc)" >&2
55 echo "$matches" >&2
56 exit 1
57fi
58exit "$rc"1// cicd/node-deep-inspect.cjs
2const util = require('util');
3util.inspect.defaultOptions.depth = null;
4util.inspect.defaultOptions.maxArrayLength = null;
5util.inspect.defaultOptions.maxStringLength = 10000;
6util.inspect.defaultOptions.breakLength = 120;