[sqlplus-script-runner-plugin] pipeline support

106 views
Skip to first unread message

Fernando Boaglio

unread,
Sep 18, 2018, 1:31:34 PM9/18/18
to Jenkins Developers

Dear staff,

I am trying to port my Jenkins plugin to have pipeline support.

According to https://jenkins.io/doc/developer/plugin-development/pipeline-integration/ I should replace AbstractBuild with Run, but I can't find similar method to:

  • AbstractBuild.getModuleRoot()
  • AbstractBuild.getModuleRoot().getRemote()
  • AbstractBuild.getWorkspace().getRemote()

Can you help me ?


Thanks in advance.

--

Fernando Boaglio

· · ·ᗧ͇̿ · · · ᗣ͇̿ᗣ͇̿ᗣ͇̿ᗣ͇̿· · · · · · ·

Slide

unread,
Sep 18, 2018, 4:44:02 PM9/18/18
to jenkin...@googlegroups.com
Hi Fernando,

You probably want to implement SimpleBuildStep and then override the perform method that takes a Run and FilePath. The FilePath that is passed in is the workspace root.

Hopefully that helps

Regards,

Alex

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e121eb62-0d2c-47b1-aff8-51d5a7a52bc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fernando Boaglio

unread,
Sep 21, 2018, 12:13:55 AM9/21/18
to Jenkins Developers
Thank you Alex,

I implemented SimpleBuildStep and it is working, but when I replaced BuildListener with TaskListener I get NO console output =/

Do I need to set anything else ?

Slide

unread,
Sep 21, 2018, 9:34:21 AM9/21/18
to jenkin...@googlegroups.com
How are you using the listener?

Fernando Boaglio

unread,
Sep 21, 2018, 2:38:20 PM9/21/18
to Jenkins Developers
Well I use listener.getLogger().println() to write what should be in the console output.

And to get the command output I use:

launcher.launch().cmds(args).envs(build.getEnvironment(listener)).stdout(listener)
.pwd(build.getModuleRoot()).join();

This is the class where I use it:


Thanks.


You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/lMUgYWFr0TQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPiUgVdhZ5QpWsuG0TZ3aUBZL%3DQUwznB6pHUvsvZBhWV-1VPMg%40mail.gmail.com.

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


--

Jesse Glick

unread,
Sep 24, 2018, 1:53:32 PM9/24/18
to Jenkins Dev
On Fri, Sep 21, 2018 at 12:14 AM Fernando Boaglio <boa...@gmail.com> wrote:
> I implemented SimpleBuildStep and it is working, but when I replaced BuildListener with TaskListener I get NO console output

Not sure what you might have done wrong, but there are plenty of
examples of `SimpleBuildStep` example if you search for them.

Fernando Boaglio

unread,
Oct 9, 2018, 9:30:55 AM10/9/18
to Jenkins Developers
Thank you Jesse, actually the solution was very simple and not related to pipeline!

I changed my package name from the Java classes and didn't change the resources ... so even though I got no errors everything just vanished... but all good now.

However, after my upgrade there is one user that is having problems with his slave machine ( https://github.com/jenkinsci/sqlplus-script-runner-plugin/issues/30 )

So, in order to get the right root folder from slave machine, I need to cast Run to AbstractBuild :

if (slaveMachine) {
filePath = ((AbstractBuild<?, ?>) build).getModuleRoot().createTempFile(SQL_TEMP_SCRIPT + System.currentTimeMillis(), SQL_PREFIX);
} else {
filePath = new FilePath(build.getRootDir().createTempFile(SQL_TEMP_SCRIPT + System.currentTimeMillis(), SQL_PREFIX));
}


In my test I tried Linux (master) and Windows 10 (slave) successfully, but this Windows 2012 R2 user is having ClassCastException:


java.lang.ClassCastException: org.jenkinsci.plugins.workflow.job.WorkflowRun cannot be cast to hudson.model.AbstractBuild

The same thing on his master machine (Windows 2012 R2 too) is running fine.

What should I do now ?
So should I get the slave root folder in another way ?


Thank you for your help.


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/lMUgYWFr0TQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1mFx4W%2BubT%2BnTgpozU%3DXVjKFukCJiybPws%2B_w%2BdAh-eQ%40mail.gmail.com.

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

Jesse Glick

unread,
Oct 9, 2018, 9:56:14 AM10/9/18
to Jenkins Dev
On Tue, Oct 9, 2018 at 9:30 AM Fernando Boaglio <boa...@gmail.com> wrote:
> in order to get the right root folder from slave machine, I need to cast Run to AbstractBuild :

No, do not do that.

> What should I do now ?

Use `SimpleBuildStep`.

Fernando Boaglio

unread,
Oct 9, 2018, 6:57:57 PM10/9/18
to Jenkins Developers

My Builder already uses it, should I do something else?

public class SQLPlusRunnerBuilder extends Builder implements SimpleBuildStep {


--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/lMUgYWFr0TQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.

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

Slide

unread,
Oct 9, 2018, 7:00:12 PM10/9/18
to jenkin...@googlegroups.com
Override the perform method that takes a Run, FilePath, TaskListener and Launcher (maybe not that order). The FilePath is the workspace. 

You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CADuSYLWixftbHoNinZi1Amrk__j8MQ2G5ACSjzju5XLqEVcpKA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages