Hello, I trying to get comfortable with Pipelines, so far its a rather unpleasant experience since I cant even get a simple script going.
1) There seem to be some arcane rules on how to iterate over some builtin Groovy/Java Types within a sandbox. I haven`t found a way that works without manually allowing the function. 2) Serialization issues for iterators. 3) Language rules seem inconsistent, for example take the createDList which seems to execute the code differently (throws errrors, need to define a explicit variable) 4) Are variables from Closures global??? Is this a Groovy thing or a bug??? There seem to be scarce information on how to write useful simple yet non-trivial pipeline scripts, even the most basic builtin types can`t be used freely. I dont know how to use maps, or if there is a prefered way (which doesnt needs approval). Layering out code into seperate functions to not step into serialization issues often results in the very same lines not working, it even appears there are clashes with variable names across all scopes?. I hope you got some feedback or pointers on the issues above. Kind Regards, Norbert Example Pipeline Code follows. This should fetch some additional modules (the url-mapping shouldnt be coded in the script and come from a configuration file later), a file .builddepencies should define name and potentially revision for a project, should be able to override these (thus a map seems fitting).All repositories should be checked out from the pipeline script, remaining build can (and will) be run from shell scripts. ----------------------------------------------------------- // Gonna be a separate, global function when its grown up def repomap = [ 'myscripts': 'ssh://git@localhost:10022/scripts.git', 'myprojekt': 'ssh://git@localhost:10022/myprojekt.git' ] node { // Mark the code checkout 'stage'.... stage 'Checkout' // Get some code from a GitHub repository //git branch: 'master', url: repomap['myprojekt'] sh('echo "fake checkout: ' + repomap['myprojekt'] + '"') sh('echo "myscripts=somebranch" > .builddepencies') // Get name of needed modules def depmap = [:] readFile('.builddepencies').eachLine { def m = (it =~ /([^=]*)=?(.*)/) depmap[m[0][1].trim()]=m[0][2].trim() m = null } // Just a check so it works (after script approval ) depmap.each { println 'map: ' + it.key + '=' + it.value } // Weird ! println 'it still defined: ' + it.key // Weirder, no name-scopes in functions?, why is this not working ?? createDList (depmap) depmap.each { name = it.key revision = it.value it = null // Ok, I could find my way around serialization issues.. dir (name) { //git url: repomap[name], changelog: false, poll: false sh('echo "fake checkout: ' + repomap[name] + '"') } } println 'end' } @NonCPS def createDList(depmap) { // Need to change the iterator name, then this works? depmap.each { println 'map: ' + it.key + '=' + it.value } } -- 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-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADYdroP99RG%2BcShBvVTbsCrrSs1oFDxRo%3DiYsRqTKcevhciBRw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.