Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upadd jenkins_script module for running arbitrary jenkins console scrip… #19640
Conversation
|
Migrated from ansible/ansible-modules-extras#3068 |
|
needs_revision |
| author: James Hogarth | ||
| module: jenkins_script | ||
| short_description: Executes a groovy script in the jenkins instance | ||
| version_added: '2.2' |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| short_description: Executes a groovy script in the jenkins instance | ||
| version_added: '2.2' | ||
| description: | ||
| - The M(jenkins_script) module takes a script and a hash of values |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hogarthj
Jan 4, 2017
Author
Contributor
grammar cleaned up to make it more readable (yay languages calling dicts hashes and vice versa).
| default: null | ||
| host: | ||
| description: | ||
| - The jenkins host to execute the script against |
This comment has been minimized.
This comment has been minimized.
gundalow
Jan 4, 2017
Contributor
All descriptions: should be full sentences, e.g. start with a capital letter, and end with a full stop.
This comment has been minimized.
This comment has been minimized.
| - The port to connect to | ||
| required: false | ||
| default: 8080 | ||
| ssl: |
This comment has been minimized.
This comment has been minimized.
gundalow
Jan 4, 2017
Contributor
To be inline with other modules please change to
validate_certs:
description: If set to C(no), the SSL certificates will not be validated. This should only set to C(no) used on personally controlled sites using self-signed certificates as it avoids verifying the source site.
The default should be True (e.g. require valid cert)
This means playbook writers need to explicitly write validate_certs: False, e.g. the default is to be secure
This comment has been minimized.
This comment has been minimized.
hogarthj
Jan 4, 2017
Author
Contributor
This isn't a validate_certs situation but rather whether the script should use http or https to connect to the jenkins server. A default quick jenkins server will have no SSL enabled, but some people will want it to use only https - particularly for a remote server.
The fetch_url enforces certificate validation by default, which is what's called, but I can see a use case for disabling validation for test environments etc so I'll add this in to be able to disable validation if required.
| port = dict(required=False, type="int", default=8080), | ||
| ssl = dict(required=False, type="bool", default=False), | ||
| user = dict(required=False, type="str",default=None), | ||
| password = dict(required=False, type="str",default=None), |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for the review. The changes requested have been pushed and the commit rebased against current devel. |
|
Thanks for the changes Looking at this again I wonder if we can simplify it further:
And delete |
|
You know you're right. That is over complicated and I'm not sure how I ended going down that route before when I first built it internally ... Probably something crazy like testing locally, then extending to manipulating a remote jenkins and then adding ssl ... but then after the incrementals no refactor to simplify. I've dropped host, port and ssl from the parameters and just left it with url. Running it through our local CI (which is where it was built for in the first place to fully automate our jenkins installs) looks good. |
|
ready_for_review |
|
@hogarthj Easily done, that's a lot better now, thanks. |
…ts against a jenkins instance
|
rebased against current devel and module added to CHANGELOG as requested thanks for taking the time to review this ready_for_review |
|
Merged, thanks :) |
|
Thanks for looking at this. Now when 2.3 gets released I can pull the internal library out :) Also this means I should probably finish my blog article on using the jenkins_script module to make life nice and simple for people ;) |
hogarthj commentedDec 22, 2016
ISSUE TYPE
COMPONENT NAME
jenkins_script
ANSIBLE VERSION
SUMMARY
The jenkins cli functionality requires an existing SSH key and user to be created.
There are a number of things that require using the jenkins groovy console to configure programatically.
Currently it requires a lot of effort to handle this for a fully automated jenkins.
This allows for an arbitrary script, with basic python templating on the string for the script, to be passed to the jenkins instance and checks for a stacktrace or authentication error for a failure condition, otherwise the script is run and the results returned.
This allows for a fully configured jenkins via groovy console scripts where the rest API does not expose something suitable - eg authentication or credentials.
For example setting a proxy for jenkins can be carried out via this script, where the variable get replaced by python basic string templating from the args dict passed to the module: