Best way to develop pipeline groovy

45 views
Skip to first unread message

Christoph Ruepprich

unread,
Oct 31, 2017, 5:51:14 PM10/31/17
to Jenkins Users
I'm new to Jenkins and am learning how to write groovy scripts for pipelines. Right now I write my code in VS Code and copy & paste it into the Jenkins' project, save and build. This gets pretty tedious and time consuming. Is there a better way to develop scripts without having to either develop them in the web UI or copy & paste them?

Thanks!

Slide

unread,
Oct 31, 2017, 6:05:14 PM10/31/17
to jenkins...@googlegroups.com
There are two things that might make your life easier:

1) Jenkinsfile, you can put this into your source control and then it will be executed as if it were in the web ui. You just change the option in the job setup to "Pipeline script from SCM" instead of "Pipeline script". Then when you push updates to the Jenkinsfile, it will use your changes.
2) The Replay. This allows you to rerun a pipeline job and make small modifications to the script that was used to test things out, then you can incorporate those changes into your Jenkinsfile.

Hope those things help

Alex

On Tue, Oct 31, 2017 at 2:51 PM Christoph Ruepprich <cruep...@gmail.com> wrote:
I'm new to Jenkins and am learning how to write groovy scripts for pipelines. Right now I write my code in VS Code and copy & paste it into the Jenkins' project, save and build. This gets pretty tedious and time consuming. Is there a better way to develop scripts without having to either develop them in the web UI or copy & paste them?

Thanks!

--
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/a2f17740-5fec-4b9b-977c-df877bdf0fbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Beck

unread,
Nov 1, 2017, 9:02:12 AM11/1/17
to jenkins...@googlegroups.com

> On 31. Oct 2017, at 22:51, Christoph Ruepprich <cruep...@gmail.com> wrote:
>
> This gets pretty tedious and time consuming. Is there a better way to develop scripts without having to either develop them in the web UI or copy & paste them?

https://jenkins.io/blog/2016/04/14/replay-with-pipeline might also help.

The declarative pipeline syntax also has a linter accessible from the Jenkins CLI, which should cut down on the trial & error executions:
https://jenkins.io/doc/book/pipeline/development/#linter

Christoph Ruepprich

unread,
Nov 1, 2017, 9:34:30 AM11/1/17
to Jenkins Users
Thanks Alex,
I think the replay is probably the better option for me.

C

Christoph Ruepprich

unread,
Nov 1, 2017, 9:36:22 AM11/1/17
to Jenkins Users
Thanks Daniel,
when making changes in replay, is there a way to promote those changes to the actual script, or would I have to copy&paste them?

Will the Jenkins CLI work only for declarative pipeline syntax, or will scripts work, too?

Cheers,
C
Reply all
Reply to author
Forward
0 new messages