Issue using Dynamic DSL in gradle with PostBuildScript

658 views
Skip to first unread message

blake

unread,
May 30, 2018, 12:45:53 PM5/30/18
to job-dsl-plugin
I've seen a number of posts similar to my question, but I've yet to find a clear solution, so
I apologize in advance if this is a duplicated.

My seed job runs and generates successfully in my Jenkins instance, but gradle is getting hung up
when I run ./gradlew test.

I'm getting the following error when trying to use the PostBuildScript plugin via Dynamic DSL:

Caused by: groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.postBuildScript() is applicable for argument types: (com.xccs.CIVBuilder$_build_closure1$_closure8$_closure27) values: [com.xccs.CIVBuilder$_build_closure1$_closure8$_closure27@426b7649]

I essentially have the same gradle.build, JobScriptsSpec.groovy, TestUtil.groovy as sheehan's wonderful example: https://github.com/sheehan/job-dsl-gradle-example.

In my build.gradle, I've added the following:

testCompile 'org.jenkins-ci.plugins:postbuildscript:2.7.0'
testPlugins
'org.jenkins-ci.plugins:postbuildscript:2.7.0'

This seemed to go out and download the plugin and whatnot, but it didn't help at all when running gradle test. I'm clearly
missing something. Can anyone help?

Here is the actual block of groovy that I'm running, which again, works in jenkins but gradle doesn't like it:

publishers {
    postBuildScript
{
        markBuildUnstable
(false)
        buildSteps
{
            postBuildStep
{
                results
(['SUCCESS', 'UNSTABLE', 'FAILURE', 'NOT_BUILT', 'ABORTED'])
                buildSteps
{
                    shell
{
                        command
("blah blah blah")
                   
}
               
}
           
}
       
}
   
}
}

Thanks in advance!

james....@silvaco.com

unread,
May 30, 2018, 1:16:30 PM5/30/18
to job-dsl-plugin
From the jobDsl API https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.postBuildScripts

The syntax is postBuildScripts plural with an s
job('example') {
    publishers {
        postBuildScripts {
            steps {
                shell('echo Hello World')
            }
            onlyIfBuildSucceeds(false)
            onlyIfBuildFails()
        }
    }
}

blake

unread,
May 30, 2018, 1:21:10 PM5/30/18
to job-dsl-plugin
That's the built-in version. I'm attempting to use the dynamic one (without the s) because I need the build step to happen in every case. See https://issues.jenkins-ci.org/browse/JENKINS-48692.

I've attached a screenshot of the job DSL API available on my jenkins system.


james....@silvaco.com

unread,
May 30, 2018, 1:22:43 PM5/30/18
to job-dsl-plugin
I also added that hello world snipet and I'm using the same sheehan's wonderful example: https://github.com/sheehan/job-dsl-gradle-example.
You don't need to :

testCompile 'org.jenkins-ci.plugins:postbuildscript:2.7.0'
testPlugins 
'org.jenkins-ci.plugins:postbuildscript:2.7.0'

Once you fix the typo, or at least I didn't.

On Wednesday, May 30, 2018 at 9:45:53 AM UTC-7, blake wrote:
Message has been deleted

blake

unread,
May 30, 2018, 1:33:42 PM5/30/18
to job-dsl-plugin
It's not a typo, but it's confusing. There are two separate things:

postBuildScripts - built-in version, not dynamic DSL. This only supports SUCCESS and FAILURE cases. It does not support UNSTABLE, NOT_BUILT or ABORTED.

postBuildScript - dynamic DSL, not the built-in version. This is what I need, and since it is not built-in gradle doesn't like it even though running the seed job in Jenkins is successful.

james....@silvaco.com

unread,
May 30, 2018, 1:36:03 PM5/30/18
to job-dsl-plugin
How did you generate your own job-dsl API web page?

Blake Devcich

unread,
May 30, 2018, 1:39:20 PM5/30/18
to job-dsl...@googlegroups.com
The DSL plugin serves this up: http://<jenkins-url>/plugin/job-dsl/api-viewer/index.html

This email may contain material that is confidential and/or proprietary that the sender intended only for specific recipients. Any review by unintended recipients, forwarding or creating derivative works without the written permission of Silvaco, Inc. or its subsidiaries is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/JOcNqsf4C9M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/692d8334-f92f-4f17-aaaf-a91d2995d0b6%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

james....@silvaco.com

unread,
May 30, 2018, 2:50:35 PM5/30/18
to job-dsl-plugin
I get the same build error.
I did notice in my dslUpdateJenkins gradle build log that It shows my installed plugins as job-dsl:1.67 (which does not support postBuildScript )
Even thought my installed version on my Jenkins server (not IDE instance) is job-dsl:1.68.
Is it possible the version of job-dsl running in the plugin is too old?

6:27:18 PM: Executing task 'dslUpdateJenkins dslUpdateJenkins --server=localhost'...

:compileJava NO-SOURCE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:resolveJenkinsPlugins UP-TO-DATE
:dslUpdateJenkins
Using server configuration 'localhost'
=== Starting Run Job DSL Task
Installed plugins: [job-dsl:1.67, structs:1.9, script-security:1.25]

On Wednesday, May 30, 2018 at 10:39:20 AM UTC-7, blake wrote:
The DSL plugin serves this up: http://<jenkins-url>/plugin/job-dsl/api-viewer/index.html
On Wed, May 30, 2018 at 12:36 PM, <james....@silvaco.com> wrote:
How did you generate your own job-dsl API web page?

On Wednesday, May 30, 2018 at 10:33:42 AM UTC-7, blake wrote:
It's not a typo, but it's confusing. There are two separate things:

postBuildScripts - built-in version, not dynamic DSL. This only supports SUCCESS and FAILURE cases. It does not support UNSTABLE, NOT_BUILT or ABORTED.

postBuildScript - dynamic DSL, not the built-in version. This is what I need, and since it is not built-in gradle doesn't like it even though running the seed job in Jenkins is successful.

This email may contain material that is confidential and/or proprietary that the sender intended only for specific recipients. Any review by unintended recipients, forwarding or creating derivative works without the written permission of Silvaco, Inc. or its subsidiaries is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

--
You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/JOcNqsf4C9M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.

james....@silvaco.com

unread,
May 30, 2018, 3:14:52 PM5/30/18
to job-dsl-plugin
I think that't it. The gradle-jenkins-jobdsl-plugin doesn't use the job-dsl version on your Jenkins server. It uses the version in the plugin and uploads with the REST API.
If you look at the change log they are currently working on updating the plugin to support 1.6.9. Until then I don't think this will compile with the plugin no matter what you add to your build.gradle

Blake Devcich

unread,
May 31, 2018, 10:15:27 AM5/31/18
to job-dsl...@googlegroups.com
As a test, I've been able to get gradle to build/test another plugin's Dynamic DSL using hipChatNotifier. So I seem to have the correct environment for testing dynamic DSL - just not with PostBuildScript :(

All it took was adding this to my build.gradle:

testPlugins 'org.jvnet.hudson.plugins:hipchat:2.1.1'

blake

unread,
May 31, 2018, 10:17:06 AM5/31/18
to job-dsl-plugin
Hmm...I'm not using that plugin, but perhaps you're suggesting a similar problem with versioning. Is there a way to confirm what versions I'm using in my gradle environment besides what's in build.gradle? I'm not very familiar with gradle itself.

james....@silvaco.com

unread,
May 31, 2018, 12:13:04 PM5/31/18
to job-dsl-plugin
If you look at the bottom of the page of https://github.com/heremaps/gradle-jenkins-jobdsl-plugin you will see plugins.
I was referring to this one

blake

unread,
May 31, 2018, 12:27:00 PM5/31/18
to job-dsl-plugin
I guess I don't understand. I'm not using the gradle-jenkins-jobdsl-plugin anywhere in my project:

$ grep -rinI gradle-jenkins-jobdsl-plugin .
$


Blake Devcich

unread,
Jun 1, 2018, 1:31:39 AM6/1/18
to job-dsl...@googlegroups.com
Hmm...I'm not using that plugin, but perhaps you're suggesting a similar problem with versioning.

Is there a way to confirm what versions I'm using in my gradle environment besides what's in build.gradle? I'm not very familiar with gradle itself.
To unsubscribe from this group and all its topics, send an email to job-dsl-plugin+unsubscribe@googlegroups.com.
To post to this group, send email to job-dsl-plugin@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/464138ca-1ee3-4593-a66f-c5ba156a676d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages