This page is intended for people who start implementing Hudson plugins. The information is presented in a question/answer style to give the page a structure. This way I hope that the required answers are found more easily. The hints presented have been collected during the implementation of my first hudson plugin which I did together with a friend of mine. Please feel free to add some of your hints too.
Every time a build is invoked the perform(Build, Launcher, BuildListener) method is executed. Within this method of your builder you can use the Launcher to execute your command. The Launcher offers several launch methods with different parameter sets. For more details have a look on the API. I used the following method:
cmd: the command that shall be executed as String
An easy example would be something like this:
Whether a Hudson-Build is successful or not depends on the return value of the perform method. In most cases this value depends on the exit code of the executed command or on thrown exceptions. If the launch method throws an exception this normally means that something went wrong so the return value should be a false (build fails). If no exception is thrown by the launch method the exit code has to be analysed. To get the exit code the following has to be done:
The launch method returns a process to which we connect with the call of join(). This way we wait until the command has been finished and get its exit code. To put all parts of this question together the following example is given:
Your images must be stored in a directory located in the src/main/webapp path.
Very simple, just use the following jelly tag :