Convert configure block to re-usable Groovy class?

56 views
Skip to first unread message

Wim Deblauwe

unread,
Jun 13, 2016, 6:04:21 AM6/13/16
to job-dsl-plugin
Hi,

I want to be able to re-use this configure block in multiple projects:

configure { project ->
        project / publishers << 'hockeyapp.HockeyappRecorder'('schemaVersion': '2') {
            applications() {
                'hockeyapp.HockeyappApplication'(plugin:'hock...@1.2.1', schemaVersion: 1) {
                    apiToken '//7f537caf75674fd3b2cb06e873855a20'
                    notifyTeam true
                    filePath 'apps/android/app/build/outputs/apk/app-release.apk'
                    mandatory false
                    downloadAllowed true
                    releaseNotesMethod(class: 'net.hockeyapp.jenkins.releaseNotes.NoReleaseNotes')
                    uploadMethod(class:'net.hockeyapp.jenkins.uploadMethod.AppCreation')
                }
            }
            debugMode false
            failGracefully false
        }
    }

I tried to do this:

configure { project ->
project / publishers << new HockeyApp(apiTokenValue: 'abc123def456',
filePathValue: 'apps/android/app/build/outputs/apk/app-release.apk').hockeyAppp()
}

With:

class HockeyApp {
CharSequence apiTokenValue
CharSequence filePathValue

public Object hockeyAppp() {
return 'hockeyapp.HockeyappRecorder'('schemaVersion': '2') {
applications() {
'hockeyapp.HockeyappApplication'(plugin:'hock...@1.2.1', schemaVersion: 1) {
apiToken apiTokenValue
notifyTeam true
filePath filePathValue
mandatory false
downloadAllowed true
releaseNotesMethod(class: 'net.hockeyapp.jenkins.releaseNotes.NoReleaseNotes')
uploadMethod(class:'net.hockeyapp.jenkins.uploadMethod.AppCreation')
}
}
debugMode false
failGracefully false
}
}
}

But that just gives me the following exception in Jenkins:

groovy.lang.MissingMethodException: No signature of method: com.pegusapps.jenkinsjobs.HockeyApp.hockeyapp.HockeyappRecorder() is applicable for argument types: (java.util.LinkedHashMap, com.pegusapps.jenkinsjobs.HockeyApp$_hockeyAppp_closure1) values: [[schemaVersion:2], com.pegusapps.jenkinsjobs.HockeyApp$_hockeyAppp_closure1@7e523a66]

Any idea on how to do this in Groovy?

regards,

Wim

Daniel Spilker

unread,
Jun 14, 2016, 4:29:18 PM6/14/16
to job-dsl...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/74865902-9168-4a4a-b02d-798ef8005ec9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages