[sqlplus-script-runner-plugin] pipeline support

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[sqlplus-script-runner-plugin] pipeline support

Fernando Boaglio

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 ?

My main class is this one:  https://github.com/jenkinsci/sqlplus-script-runner-plugin/blob/master/src/main/java/org/jenkinsci/plugins/sqlplusscriptrunner/SQLPlusRunner.java

Thanks in advance.

--

Fernando Boaglio

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

--
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

slide
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

On Tue, Sep 18, 2018, 10:31 Fernando Boaglio <[hidden email]> wrote:

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

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

--
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 [hidden email].
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPiUgVcZa8wUYzcZ4jo27OcDXJ9psHkgSAokMOzDVh%2B0bwZ9Pw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

Fernando Boaglio
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 ?


Em terça-feira, 18 de setembro de 2018 17:44:02 UTC-3, slide escreveu:
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

On Tue, Sep 18, 2018, 10:31 Fernando Boaglio <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ldQ72YhMCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">boa...@...> wrote:

Dear staff,

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

According to <a href="https://jenkins.io/doc/developer/plugin-development/pipeline-integration/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fdeveloper%2Fplugin-development%2Fpipeline-integration%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHbG-vapbf3zI9CkUwbVzkOshJpRw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fdeveloper%2Fplugin-development%2Fpipeline-integration%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHbG-vapbf3zI9CkUwbVzkOshJpRw&#39;;return true;">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 ?

My main class is this one:  <a href="https://github.com/jenkinsci/sqlplus-script-runner-plugin/blob/master/src/main/java/org/jenkinsci/plugins/sqlplusscriptrunner/SQLPlusRunner.java" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fsqlplus-script-runner-plugin%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fsqlplusscriptrunner%2FSQLPlusRunner.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAhao1HnFz_6KPnPsa0D7wQ1expw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fsqlplus-script-runner-plugin%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Forg%2Fjenkinsci%2Fplugins%2Fsqlplusscriptrunner%2FSQLPlusRunner.java\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHAhao1HnFz_6KPnPsa0D7wQ1expw&#39;;return true;">https://github.com/jenkinsci/sqlplus-script-runner-plugin/blob/master/src/main/java/org/jenkinsci/plugins/sqlplusscriptrunner/SQLPlusRunner.java

Thanks in advance.

--

Fernando Boaglio

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

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ldQ72YhMCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/e121eb62-0d2c-47b1-aff8-51d5a7a52bc9%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/e121eb62-0d2c-47b1-aff8-51d5a7a52bc9%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/e121eb62-0d2c-47b1-aff8-51d5a7a52bc9%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/e121eb62-0d2c-47b1-aff8-51d5a7a52bc9%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/5ef0e4f4-026c-40ec-91de-a09332a33806%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

slide
How are you using the listener?

On Thu, Sep 20, 2018, 21:14 Fernando Boaglio <[hidden email]> wrote:
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 ?


Em terça-feira, 18 de setembro de 2018 17:44:02 UTC-3, slide escreveu:
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

On Tue, Sep 18, 2018, 10:31 Fernando Boaglio <[hidden email]> wrote:

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

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

--
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 [hidden email].
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/5ef0e4f4-026c-40ec-91de-a09332a33806%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

Fernando Boaglio
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.


On Fri, Sep 21, 2018 at 10:34 AM Slide <[hidden email]> wrote:
How are you using the listener?

On Thu, Sep 20, 2018, 21:14 Fernando Boaglio <[hidden email]> wrote:
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 ?


Em terça-feira, 18 de setembro de 2018 17:44:02 UTC-3, slide escreveu:
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

On Tue, Sep 18, 2018, 10:31 Fernando Boaglio <[hidden email]> wrote:

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

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

--
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 [hidden email].
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/5ef0e4f4-026c-40ec-91de-a09332a33806%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
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.


--

Fernando Boaglio

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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CADuSYLVNJy3eF%3Dh1vJAbvX7MESs%3DuW2EYj4k%2BXDiHDgF5hqAwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

Jesse Glick-4
In reply to this post by Fernando Boaglio
On Fri, Sep 21, 2018 at 12:14 AM Fernando Boaglio <[hidden email]> 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.

--
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

Fernando Boaglio
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.


On Mon, Sep 24, 2018 at 2:53 PM Jesse Glick <[hidden email]> wrote:
On Fri, Sep 21, 2018 at 12:14 AM Fernando Boaglio <[hidden email]> 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.

--
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 [hidden email].
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.


--

Fernando Boaglio

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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CADuSYLVO4qX6zvDzXk_UMkwJ2z4uK-gL2XwQ_8wfn17EbNw4Gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

Jesse Glick-4
On Tue, Oct 9, 2018 at 9:30 AM Fernando Boaglio <[hidden email]> 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`.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2tnebuAzt_oCOqnXBf8_bcz_rkBcwu7iFHyi_sSisenA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

Fernando Boaglio

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

public class SQLPlusRunnerBuilder extends Builder implements SimpleBuildStep {


On Tue, Oct 9, 2018 at 10:56 AM Jesse Glick <[hidden email]> wrote:
On Tue, Oct 9, 2018 at 9:30 AM Fernando Boaglio <[hidden email]> 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`.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr2tnebuAzt_oCOqnXBf8_bcz_rkBcwu7iFHyi_sSisenA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--

Fernando Boaglio

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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CADuSYLWixftbHoNinZi1Amrk__j8MQ2G5ACSjzju5XLqEVcpKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [sqlplus-script-runner-plugin] pipeline support

slide
Override the perform method that takes a Run, FilePath, TaskListener and Launcher (maybe not that order). The FilePath is the workspace. 

On Tue, Oct 9, 2018 at 3:57 PM Fernando Boaglio <[hidden email]> wrote:

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

public class SQLPlusRunnerBuilder extends Builder implements SimpleBuildStep {


On Tue, Oct 9, 2018 at 10:56 AM Jesse Glick <[hidden email]> wrote:
On Tue, Oct 9, 2018 at 9:30 AM Fernando Boaglio <[hidden email]> 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`.

--
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 [hidden email].

--

Fernando Boaglio

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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CADuSYLWixftbHoNinZi1Amrk__j8MQ2G5ACSjzju5XLqEVcpKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPiUgVe5vQ4pi5c0czVMTAz1pN2pb69mCNk3EryDEvv65ONhYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.