call a Jenkins plugin from a pipeline

1,849 views
Skip to first unread message

Jan Chaloupecky

unread,
Apr 25, 2016, 1:06:25 PM4/25/16
to Jenkins Users
Hello,
I have a Jenkinsfile in my project that triggers different build steps from checking out the sources through testing/building my project. I would like to know if I can call some other Jenkins plugins from the Jenkinsfile. In my non-pipeline projects I was using some "post build actions" such as 


Is this something that has to be implemented by the plugin itself or is there a way to call those plugins from the Jenkinsfile ?

cheers,
Jan

Mark Waite

unread,
Apr 25, 2016, 1:12:40 PM4/25/16
to Jenkins Users
The JUnit plugin has been extended to support pipeline.  Refer to https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md for an example of how to use it in a pipeline.

I don't see any mention of pipeline enabling changing in the BitBucket Build Status Notifier Plugin or the Cobertura Plugin.

Mark Waite

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7f670704-51a6-4d95-ab22-a7f08746eb36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan Chaloupecky

unread,
Apr 25, 2016, 1:20:52 PM4/25/16
to jenkins...@googlegroups.com, Mark Waite
Ok thanks,
there is a open ticket for the Bitbucket notifier

So this means that each plugin has to implement the pipeline support before it can be used.

thanks
Jan
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/ZTaU0kUOqGU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtG-8E%3DafKyEK9cCrd%3D2mpjL7s8Yfoy7zThAN3q1vjFj_g%40mail.gmail.com.

Attila Vangel

unread,
Jul 6, 2016, 2:04:18 PM7/6/16
to Jenkins Users, mark.ea...@gmail.com
I tried to trick it like this, and that's the closest I could get to making it work (but unfortunately it does not work, see below):

        step([$class: 'hudson.plugins.cobertura.CoberturaPublisher',
              coberturaReportFile: '.ci/coverage-cobertura/cobertura-coverage.xml',
              onlyStable: false,
              failUnhealthy: false,
              failUnstable: false,
              autoUpdateHealth: false,
              autoUpdateStability: false,
              zoomCoverageChart: false,
              failNoReports: true,
              sourceEncoding: 'ASCII'
        ])

(I got the class name and field names from another job's config.xml, did not really look it up in any documentation. I know I miss the healthyTarget, unhealthyTarget, failingTarget fields, but those are some complex structures, and I really don't know how to set them.)

But something is wrong, I got some generic error (I tried it with Jenkins 2.10):

java.lang.IllegalArgumentException: argument type mismatch
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:193)
	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:104)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:134)
	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113)
	at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:101)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
	at WorkflowScript.run(WorkflowScript:133)
	at ___cps.transform___(Native Method)
	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
	at sun.reflect.GeneratedMethodAccessor484.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
	at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
	at sun.reflect.GeneratedMethodAccessor487.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:29)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:106)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:29)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:276)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:78)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:185)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:183)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

There is some room for improving this error message...

I tried to experiment with changing the boolean values to string, but then I got:

java.lang.ClassCastException: hudson.plugins.cobertura.CoberturaPublisher.onlyStable expects boolean but received class java.lang.String at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:317) at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:248) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:192) at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:305) at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:248) at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:192) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:104) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:134)
...

So that did not help, so undone this change, but as mentioned before it still fails with the generic "argument type mismatch" error.
If anyone knows how to fix this, please do not hesitate to post it!

Thx,
Attila

Antonio Muñiz

unread,
Jul 20, 2016, 12:01:36 PM7/20/16
to jenkins...@googlegroups.com
On Wed, Jul 6, 2016 at 8:04 PM, Attila Vangel <vangel...@gmail.com> wrote:
> CoberturaPublisher


`cobertura-plugin` is not compatible with Pipeline yet. It requires
some code fixes.

--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Balaji Lalapeta

unread,
May 7, 2018, 8:09:23 AM5/7/18
to Jenkins Users
Hi Antonio,

`cobertura-plugin` is compatible with Pipeline script in Jenkins?

If yes, Pl. share the code and rest of required details urgent.

Thanks for your support and understand.

Regards,
Balaji
Reply all
Reply to author
Forward
0 new messages