-
Notifications
You must be signed in to change notification settings - Fork 830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rundeck] Support for shouldIncludeRundeckLogs #493
[Rundeck] Support for shouldIncludeRundeckLogs #493
Conversation
Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests |
How can I test this without a running instance of Rundeck? |
In case it would be enough for you to verify that the same parameters are passed to a Rundeck instance you could compare XML created with manual marking that checkbox in Jenkins job configuration with the XML generated from Jenkins Job DSL with my change. Regarding manual functional tests with Rundeck in my current build I have the following code and it works :).
|
I always do some manual testing in Jenkins to ensure that there are no type in element names. I could not save the job configuration page because saving already seems to require a running instance of Rundeck. |
Rundeck is a jar which can be run without installation. It is only required to create project and job and generate access token, but If you prefer I can send you a fragment of XML created with manual clicking in Jenkins. |
shouldWaitForRundeckJob(boolean value = true) // defaults to false if omitted | ||
shouldFailTheBuild(boolean value = true) // defaults to false if omitted | ||
shouldIncludeRundeckLogs(boolean value = true) // defaults to false if omitted - since 1.35 | ||
shouldWaitForRundeckJobAndIncludeRundeckLogs(boolean value = true) // sets both options as shouldIncludeRundeckLogs requires shouldWaitForRundeckJob - since 1.35 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not include shortcut methods, just set shouldWaitForRundeckJob when setting shouldIncludeRundeckLogs
9c3f79e
to
94b2411
Compare
I reworked the code after your comments. |
By the way I also simplified a few tests in the neighborhood. |
Great Feature! 👍 |
@@ -2950,7 +2991,7 @@ class PublisherContextSpec extends Specification { | |||
'test' | 'test' | null | |||
} | |||
|
|||
def 'call s3 with invalid storage class'(String storageClass) { | |||
def 'call s3 with invalid storage class'() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not fix unrelated tests, open a separate pull request for that
This does not work in Jenkins, the checkbox is not set. Test this in Jenkins and fix the PR. |
bd1dd52
to
a298072
Compare
In the end there was no technical error in code, but Rundeck has inconsistently named variables and I had Is there something else I should update in regards to recent documentation changes? |
Add GroovyDoc for the new DSL method. And so not refactor unrelated tests, keep the diff at a minimum. |
a298072
to
40a7c61
Compare
Documentation moved from markdown file to GroovyDoc. I reverted my changes to unrelated test in the previous commit... except one which was next to rundeck tests (which I missed). Currently only Rundeck related tests are modified. |
a048f76
to
9ba2417
Compare
} | ||
|
||
then: | ||
Node rundeckNode = context.publisherNodes[0] | ||
rundeckNode.name() == 'org.jenkinsci.plugins.rundeck.RundeckNotifier' | ||
rundeckNode.jobId[0].value() == 'jobId' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert these changes, no need to use the safe navigation operator here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During the new feature development I came across a situation (after I renamed a node name) when assertion like that failed. The error message was:
java.lang.NullPointerException: Cannot invoke method value() on null object
From the error message I know that there wasn't node with given name, but I cannot say why - developer has to debug it or add some additional logging statement before.
After my change the error message became much more meaningful:
rundeckNode.includeRundeckLogsWrongName[0]?.value() == true
| | | | |
| [] null null false
org.jenkinsci.plugins.rundeck.RundeckNotifier[attributes={}; value=[jobId[attributes={}; value=jobId],
options[attributes={}; value=], nodeFilters[attributes={}; value=], tag[attributes={}; value=],
shouldWaitForRundeckJob[attributes={}; value=true], shouldFailTheBuild[attributes={}; value=false],
includeRundeckLogs[attributes={}; value=true]]]
It is in some sense a boiler plate code, but unfortunately Spock currently doesn't support it. I personally prefer a need to add additional ?
to get verbose error message in case of regression.
@daspilker any plans for merging this PR? |
9ba2417
to
6813d27
Compare
I rebased my PR - there are still conflicts in HOME.md. I already removed all non rundeck related tests as requested by @daspilker. |
6813d27
to
f960f74
Compare
14e16e2
to
79a0ad5
Compare
79a0ad5
to
91b4a08
Compare
As shouldIncludeRundeckLogs requires shouldFailTheBuild to be set I also added a shortcut
shouldWaitForRundeckJobAndIncludeRundeckLogs
. It is convenient, but I don't know how it fits into job-dsl conventions.