Your task is to fix the CI pipeline tool so that every command updates the data correctly and prints the correct success message or error reason. It reads the state from data/pipeline.json, processes the start, stage and retry commands, and writes the updated state back.
├── data/
│ └── pipeline.json # Persistent pipeline state (stages and runs)
├── src/
│ ├── main/java/com/pipeline/
│ │ ├── Commands.java # Command handlers
│ │ ├── FileIo.java # State file load and save
│ │ ├── Main.java # CLI entry point
│ │ ├── Models.java # Data models
│ │ └── Parser.java # JSON parsing
│ └── test/java/com/pipeline/
│ └── CommandsTest.java # Unit tests
├── pipeline # CLI launcher script
├── pom.xml # Maven project configuration
├── run.sh # Setup and run script
├── reset.sh # Restore data/pipeline.json to its initial state
├── test.sh # Test script (writes junit.xml)
└── README.md
mvn -B -ntp -DskipTests packagebash run.shbash test.shRestore data/pipeline.json to its initial state.
bash reset.shEach example below runs independently against the initial data/pipeline.json and shows only the records it changes.
Command:
./pipeline start R48Output:
R48 started: build
Final data/pipeline.json, new record appended at the end:
{"run":"R48","stage":"build","status":"running","results":[]}The run begins at build, the first name in stages, with no results yet.
Command:
./pipeline stage R43 passOutput:
R43: test passed, now deploy
Final data/pipeline.json, changed record only:
{"run":"R43","stage":"deploy","status":"running","results":[{"stage":"build","result":"pass"},{"stage":"test","result":"pass"}]}The result is appended for the stage that just ran, and the run moves to deploy.
Commands:
./pipeline stage R43 passed
./pipeline stage R41 bogusOutputs:
Error: INVALID_RESULT
Error: NOT_RUNNING
data/pipeline.json: unchanged.
R43 is running, so its misspelled result is rejected as invalid. R41 is not running, and that check comes first, so the bad result is never reached.
Command:
./pipeline retry R45Output:
R45: retrying deploy
Final data/pipeline.json, changed record only:
{"run":"R45","stage":"deploy","status":"running","results":[{"stage":"build","result":"pass"},{"stage":"test","result":"pass"},{"stage":"deploy","result":"fail"}]}The run is running again on deploy, and the failed result stays on file.
Commands:
./pipeline retry R43
./pipeline retry R99Outputs:
Error: NOT_FAILED
Error: RUN_NOT_FOUND
data/pipeline.json: unchanged.
R43 is still running, and R99 is not on file at all.