Cutton Eye
Cutton Eye

Reputation: 3559

Use IDE to generate pipline script for jenkins

I need to overload jenkins functions to debug pipeline script in IDE.

I'm new to java/groovy etc. I'm going to write a several hundred lines scripted pipeline. Groovy is based on java. As I'm new I prefer the function name completion/suggestion and a debugging feature would be awesome where I can walk through the lines step by step and see what is in the vars.

I set up a eclipse Luna with the groovy-plugin. Which is actually working =)! (for newest eclipse the plugin is not yet ready). Also debugging is quiet cool!

But special jenkins expressions will still throw errors.

node(MasterName){ ... }
sh
...

Is there a chance to overload those functions?

Just killing the error, not performing any actions. Maybe converting it to a print like "I'm executing script XYZ" or "Switching to node BLUBB"? The outcome should be a copy paste script, for checking in and running with jenkins without major changes.

Is there any better way?

Upvotes: 0

Views: 540

Answers (1)

Cutton Eye
Cutton Eye

Reputation: 3559

In the end it turned out, that even if you omit the pipeline specific expressions, you will still have trouble. In some more complex situations e.g. calling a constructor with super in a extended class and executing a function afterwards, it does not behave the same then in my local python interpreter.

So what I did was an error to assume, my Ubuntu system default groovy interpreter would work the same like the jenkins interpreter. It would be nice to run a debugger inside the jenkins environment, or going step by step through the pipeline script and see how it is actually working without a print in every second line.

Upvotes: 1

Related Questions