# jenkins-config

Repository for Jenkins configuration.

## Repository Layout

There is a top-level folder for each Jenkins controller instance, with subfolders for each type of configuration.

### Jobs

Job definitions are stored in the `jobs` subfolder of each top-level folder.

Jenkins jobs are managed as code using the [Job DSL plugin](https://plugins.jenkins.io/job-dsl/). 
The Job DSL API for a specific Jenkins instance can be found at `<JENKINS_URL>/plugin/job-dsl/api-viewer/index.html`.

#### Validation

Job DSL scripts are validated as part of the pipeline via the [JobDslScriptTest unit test](./lib/src/test/groovy/jenkins/config/JobDslScriptTest.groovy).
This uses the Jenkins test harness to execute the scripts within the context of a real Jenkins instance. 
The Jenkins and plugin versions used for this are defined in the [build.gradle](./lib/build.gradle).

## Builds

Gradle is the build system of choice for this project and is used primarily to compile and run tests. Gradle wrapper is also utilized to manage Gradle versions.

## Testing

Tests should utilize Junit 5+ syntax, and should be added to [./lib/src/test/groovy/jenkins/config](./lib/src/test/groovy/jenkins/config).

Run tests using the gradle wrapper command:
```sh
./gradlew test
```

## Pipeline

The Jenkins pipeline will run tests on PRs. On merge the pipeline will also automatically apply the configuration to the Jenkins controller.
