Skip to content

Just a little example to create a job dsl with maven and use a yaml file as configuration

License

Notifications You must be signed in to change notification settings

maikheene/jenkins-job-dsl-maven-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create a jenkins job dsl with maven and use a yaml configuration

Create a seed job

  • Create a new Freestyle project
  • In the Source Code Management select the git option
    • Add the Repository URL and selected your credentials
  • In the Build section, add the build step Process Job DSL
    • Select the option Look on File system
    • Add your filename to the DSL Scripts field
      • For this example enter src/main/groovy/jobs/**/*.groovy
    • Open Advanced section and put src/main/groovy and src/main/lib/*.jar to the Additional classpath field in spepareated rows. (Imports the snakeYaml libary and other classes)
  • Save

File structure

.
├── src
│   ├── main
│   │   ├── groovy          
|   |   |   └── jobs        # DSL script files
|   |   |   └── utilities   # created classes for job DSL
|   |   |   └── lib         # libs that the job DSL is use 
│   │   └── resources       # resources (like scripts etc.) for job DSL
│   └── test
│       └── groovy          # unit tests
└── pom.xml                 # maven build file

Yaml configuration file

In the job_buildscript.grovy file you find the constant:

final YAML_FILE_CONFIG_PATH = "/your/path/to/the/yaml/file"

Here is an example for the current configuration:

ProjectName:
  git:
    - url: {git url}
    - branches_to_build: 
      - develop
      - release
      - master
    - credential_key_id: {credential_id_from_jenkins}
  java: 
    - jdk_version: 8
  builds:
    - keep_builds: 5
    - keep_day: 90

About

Just a little example to create a job dsl with maven and use a yaml file as configuration

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published