Skip to content
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

Merged

Conversation

szpak
Copy link

@szpak szpak commented May 26, 2015

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.

@jenkinsadmin
Copy link
Member

Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests

@daspilker
Copy link
Member

How can I test this without a running instance of Rundeck?

@szpak
Copy link
Author

szpak commented Jun 1, 2015

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.
I have to admit I haven't test the Job DSL plugin version with my change and I end automatic testing on PublisherContextSpec which suggests that proper nodes are created in generated XML. How do you usually test the new features like that?

Regarding manual functional tests with Rundeck in my current build I have the following code and it works :).

configure { projectNode ->
    projectNode / 'publishers' / 'org.jenkinsci.plugins.rundeck.RundeckNotifier' << {
        'includeRundeckLogs'('true')
    }
}

@daspilker
Copy link
Member

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.

@szpak
Copy link
Author

szpak commented Jun 1, 2015

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
Copy link
Member

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

@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch from 9c3f79e to 94b2411 Compare June 4, 2015 23:23
@szpak
Copy link
Author

szpak commented Jun 4, 2015

I reworked the code after your comments.

@szpak
Copy link
Author

szpak commented Jun 4, 2015

By the way I also simplified a few tests in the neighborhood.

@burdandrei
Copy link
Contributor

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'() {
Copy link
Member

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

@daspilker
Copy link
Member

This does not work in Jenkins, the checkbox is not set. Test this in Jenkins and fix the PR.

@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch 2 times, most recently from bd1dd52 to a298072 Compare September 3, 2015 17:43
@szpak
Copy link
Author

szpak commented Sep 3, 2015

In the end there was no technical error in code, but Rundeck has inconsistently named variables and I had shouldIncludeRundeckLogs instead of includeRundeckLogs. I tested it manually with Jenkins 1.609.2.

Is there something else I should update in regards to recent documentation changes?

@daspilker
Copy link
Member

Add GroovyDoc for the new DSL method. And so not refactor unrelated tests, keep the diff at a minimum.

@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch from a298072 to 40a7c61 Compare September 19, 2015 19:46
@szpak
Copy link
Author

szpak commented Sep 19, 2015

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.

@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch 2 times, most recently from a048f76 to 9ba2417 Compare September 19, 2015 19:55
}

then:
Node rundeckNode = context.publisherNodes[0]
rundeckNode.name() == 'org.jenkinsci.plugins.rundeck.RundeckNotifier'
rundeckNode.jobId[0].value() == 'jobId'
Copy link
Member

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

Copy link
Author

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.

@kamilszymanski
Copy link
Contributor

@daspilker any plans for merging this PR?
@szpak you need to rebase this PR - there are conflicts to be resolved

@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch from 9ba2417 to 6813d27 Compare November 15, 2015 13:35
@szpak
Copy link
Author

szpak commented Nov 15, 2015

I rebased my PR - there are still conflicts in HOME.md.

I already removed all non rundeck related tests as requested by @daspilker.

@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch from 6813d27 to f960f74 Compare January 31, 2016 11:55
@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch 2 times, most recently from 14e16e2 to 79a0ad5 Compare January 31, 2016 12:40
@szpak szpak force-pushed the feature/rundeck/includeRundeckLogs branch from 79a0ad5 to 91b4a08 Compare January 31, 2016 14:37
@daspilker daspilker merged commit 91b4a08 into jenkinsci:master Feb 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants