Re: Anyway to programatically update a Jenkinsfile?

2019-10-17 Thread Torsten Reinhard
we donĀ“t use Jenkinsfile(s) at all - instead we generate all the jobs using the Job-DSL. The jobs than either have the full (generated) code in it - or even better they just call some functions of a shared library. Any modifications can be applied by a new version of the shared library - or by a

Re: Anyway to programatically update a Jenkinsfile?

2019-10-06 Thread Martin d'Anjou
Use a template engine to generate Jenkins files, I suggest the StringTemplate template engine. It's a purely declarative template. There are examples in the intro doc that you can try in

Re: Anyway to programatically update a Jenkinsfile?

2019-10-03 Thread Tim Black
I have to agree with Jeremy on this. Using a templating engine like m4 or jinja2 is superior to programmatic generation of groovy, if you need to do it on the fly. Why? Simplicity and Readability. I inherited a build system that is based on using a multibranch pipeline with a Jenkinsfile that l

Re: Anyway to programatically update a Jenkinsfile?

2019-10-02 Thread Slide
Pipeline scripts are a subset of groovy, so you may want to look in the direction of the available groovy AST modification methods. I am not sure how well it will work on declarative (though it should), but it's the best bet I believe. On Wed, Oct 2, 2019 at 12:07 AM Jeff Sault wrote: > Thanks b

Re: Anyway to programatically update a Jenkinsfile?

2019-10-02 Thread Jeff Sault
Thanks but i dont think it suits in my case, i need to update a bunch of jenkinsfiles owned by other teams. Surely theres a way to parse a Jenkinsfile into an object, make changes and then write the updated Jenkinsfile back out to the filesystem? On Tuesday, October 1, 2019 at 4:59:44 PM UTC+1,

Re: Anyway to programatically update a Jenkinsfile?

2019-10-01 Thread jeremy mordkoff
I use a templating tool (m4) so I can build up a groovy script using macros. In the first stage of my Jenklinsfiie, I call a bash script that generates a groovy script, which I then load and execute. The loaded script has N stages. Note that if the ordering of your stages changes, jenkins will

Anyway to programatically update a Jenkinsfile?

2019-10-01 Thread Jeff Sault
Does anyone know of any libraries/tools that will allow me to add/remove/update sections of a Jenkinsfile programatically? I have a load of different projects which I need to update to include some new mandatory parameters. I'd like to go down the 'shared library' route but in this instance its