Jsonnet Project Template
Jsonnet provides functions, variables, loops, and conditionals that allow for fully paramaterized YAML configuration.
This project contains two files:
This simple example contains a Jsonnet script that generates two unique jobs for a scenario where you might want to dynamically generate your testing jobs:
local param_job serves as the template for all the jobs. It also takes advantage of the
parallel keyword to create two copies of each job.
From here you can use Jsonnet to generate CI YAML in an easy way. To learn more about Jsonnet, check out its tutorial or getting started guide. The complete GitLab CI YAML Configuration Reference is also available to help.
.gitlab-ci.yml file contains two important jobs:
This job fetches the Jsonnet package from
apk and runs it to create the
generated-config.yml, which is the emitted YAML. The
generated-config.yml is stored as an artifact to make it available for triggering in the next step.
trigger-tests is a trigger job responsible for starting the dynamic child pipeline. It takes the YAML artifact from the previous
jsonnet job and starts the dynamic pipeline.