SVG
SVG

JSON example

Next to EDN and YAML, MonkeyCI also supports JSON. This is a very widely supported format, and the lingua franca for just about every machine-to-machine communication over the web.

Similar to EDN and YAML, JSON is only usable for simple scripts. These three formats are mostly interchangeable so you can use either. You can even combine them, as MonkeyCI will read all files with supported extensions in the .monkeyci/ directory.

Below is a basic build configuration for a single job, stored in .monkeyci/build.json:

{
  "id": "echo-job",
  "image": "docker.io/alpine:latest",
  "script": ["echo \"Hi there, this is a test\""]
}

Of course, multiple jobs are also possible:

[
  {
    "id": "test",
    "image": "docker.io/maven:latest",
    "script": ["mvn verify"],
    "saveArtifacts":
    [
      { "id": "target", "path": "target/"}
    ]
  },
  {
    "id": "publish",
    "image": "docker.io/maven:latest",
    "script": ["mvn deploy:deploy"],
    "dependencies": ["test"],
    "restoreArtifacts":
    [
      { "id": "target", "path": "target/"}
    ]
  }
]

This build script declares two jobs: test, which runs Java unit tests using Apache Maven, and publish, which publishes the artifacts and which is dependent on the test job in order to execute. The test job also saves artifacts to pass on to the publish job.

As stated, this is only useful for the simplest build scripts. As soon as you need conditions or you want to run action jobs, you'll need to code your scripts using Clojure. Don't forget you can also combine JSON with Clojure code!