Skip to content

Creates, executes and then deletes a temporary Jenkins job with a Job DSL script.

License

Notifications You must be signed in to change notification settings

meierw/jenkins-job-dsl-exec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jenkins_job_dsl_exec

Build Status

Ansible role, that creates, executes and then deletes a temporary Jenkins job containing a Job DSL script.

Requirements

  • A Jenkins service, with the Job DSL plugin installed.
  • The ability to execute jenkins_script against said Jenkins service.

Role Variables

jenkins_job_dsl_url: http://localhost:8080
jenkins_job_dsl_user: admin
jenkins_job_dsl_password: admin

The URL, username and password for authenticating with Jenkins. Will be used to execute jenkins_script.


jenkins_job_dsl_temp_job_name: C4lpe7GMX8S0pdZV6RWbKAkBfKWCPAOgAL9MGL03

The name of the temporary job, which will be used for the DSL script execution. Should keep this as a complicated string of characters, to avoid collision with actual job names.


jenkins_job_dsl_content: |
    job('dsl-example-job') {
        steps {
            shell('echo Hello world!')
        }
    }

The DSL script, that will be run. You can specify it inline like in the example, or us something like jenkins_job_dsl_content: "{{ lookup('file', 'files/myDslScript.groovy') }}" if you want your playbook to be more neat.


jenkins_job_dsl_temp_job_run: true

Should the newly created temporary job be run. You may want to disable this if you have a different plan for when or how you want to run it.


jenkins_job_dsl_temp_job_delete: true

Should the temporary job be deleted after running it. You may want to disable this, if you're not getting the desired result and want to check out the build log in Jenkins. Does nothing if jenkins_job_dsl_temp_job_run is false.


jenkins_job_dsl_temp_job_running_checks: 10

How many times should the role check, if the job has stopped running, before deleting it. The role performs a check every second, so this amount is also the checking timeout limit in seconds. Does nothing if jenkins_job_dsl_temp_job_delete is false.

Example Playbook

- hosts: servers
  roles:
    - { role: meierw.jenkins_job_dsl_exec }

License

MIT

Author Information

About

Creates, executes and then deletes a temporary Jenkins job with a Job DSL script.

Resources

License

Stars

Watchers

Forks

Packages

No packages published