CI helper scripts often choose a named check, build the command, and report a compact status line for the pipeline log.

Program

Play the script to choose the CI stage and see the modeled command and result.

stage
ci_step_gate.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash

stage="test"
case "$stage" in
    test) command="mvn test"; result="pass" ;;
    lint) command="shellcheck scripts"; result="pass" ;;
esac
echo "$stage:$command:$result"
#!/usr/bin/env bash

stage="lint"
case "$stage" in
    test) command="mvn test"; result="pass" ;;
    lint) command="shellcheck scripts"; result="pass" ;;
esac
echo "$stage:$command:$result"
  1. stage ← test

    3stage="test"4case "$stage" in
    values this stepteststage
  2. case "$stage" in

    3stage="test"4case "$stage" in5    test) command="mvn test"; result="pass" ;;
    values this stepteststage
  3. command ← mvn test, result ← pass

    4case "$stage" in5    test) command="mvn test"; result="pass" ;;6    lint) command="shellcheck scripts"; result="pass" ;;
    values this stepmvn testcommandpassresult
  4. echo "$stage:$command:$result"

    7esac8echo "$stage:$command:$result"
    outputtest:mvn test:pass
    values this stepteststagemvn testcommandpassresult
  1. stage ← lint

    3stage="lint"4case "$stage" in
    values this steplintstage
  2. case "$stage" in

    3stage="lint"4case "$stage" in5    test) command="mvn test"; result="pass" ;;
    values this steplintstage
  3. command ← shellcheck scripts, result ← pass

    5    test) command="mvn test"; result="pass" ;;6    lint) command="shellcheck scripts"; result="pass" ;;7esac
    values this stepshellcheck scriptscommandpassresult
  4. echo "$stage:$command:$result"

    7esac8echo "$stage:$command:$result"
    outputlint:shellcheck scripts:pass
    values this steplintstageshellcheck scriptscommandpassresult
CI stage A CI stage names one check in the automated pipeline.
gate A gate reports pass or fail before later deployment steps run.
log line Stable status lines make pipeline logs easy to scan.