Hi -
I'm tending to use Declarative as my preference after starting with the
scripted like you did. I'm finding:
- With declarative can have more of the job configuration in the
Jenkinsfile like parameters and SCM polling. It means the Jenkins server
can pick up the Jenkinsfiles for projects automatically with a MultiBranch
pipeline container or GH Organisation. So you don't have to create the jobs
configs, just add the Jenkinsfile in the repo with the code.
- I really like the post section handling in Declarative for handling
errors and failures. You can have post handing at the job or stage level.
It means you don't need the try-catch-finally handling that you have. Seems
cleaner to me.
- Declaration and use of tools is cleaner. Also setup of environment
variables for the build.
I don't see any issues with your scripted pipeline. I would use the
"error('Some failure occurred')" step instead of throwing / re-throwing
exceptions for errors, It allows to generate the error message at the point
the failure occurs. I do google searches against github looking for
interesting Jenkinsfiles or look in the CloudBees / Jenkins repos there.
I can recommend looking at the Declarative pipeline!
--Bill
On Friday, 17 March 2017 03:55:48 UTC, Nick Le Mouton wrote:
>
> Hi,
>
> I'm just getting my head around pipeline as code and have converted my
> previous Jenkins job/ant build targets to a Jenkinsfile. As I was looking
> for documentation on the Jenkins site, I'm seeing mentions of declarative
> pipelines and it differs from what I've written.
>
> Which method should I be looking to use (especially with blue ocean)?
> Declarative or scripted? Why should I be using one over the other?
>
> Can I also get some feedback on my Jenkinsfile (
> https://gist.github.com/NoodlesNZ/bf9b50cab82093097796d354e37083f0)? It's
> hard to find examples beyond "hello world"/simple pipelines.
>
> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/5bb89e53-6b98-458e-a406-8870b75feb03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.