Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Java: CI Pipeline

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.

Project Structure

├── 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

Commands

Install

mvn -B -ntp -DskipTests package

Run

bash run.sh

Test

bash test.sh

Reset

Restore data/pipeline.json to its initial state.

bash reset.sh

Examples

Each example below runs independently against the initial data/pipeline.json and shows only the records it changes.

Example 1: Starting a run opens it at the first stage

Command:

./pipeline start R48

Output:

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.

Example 2: A passing stage moves the run to the next one

Command:

./pipeline stage R43 pass

Output:

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.

Example 3: Only pass and fail are accepted, and the run is checked first

Commands:

./pipeline stage R43 passed
./pipeline stage R41 bogus

Outputs:

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.

Example 4: Retrying puts a failed run back on the same stage

Command:

./pipeline retry R45

Output:

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.

Example 5: Only a failed run can be retried

Commands:

./pipeline retry R43
./pipeline retry R99

Outputs:

Error: NOT_FAILED
Error: RUN_NOT_FOUND

data/pipeline.json: unchanged.

R43 is still running, and R99 is not on file at all.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages