FreeStyleProject p = (FreeStyleProject) build.getProject();
ORIGIN_BUILDER = (CommandInterpreter) builder;
NEW_BUILDER = new Shell("echo hello");
p.getBuildersList().remove(ORIGIN_BUILDER);
p.getBuildersList().add(NEW_BUILDER);
p.save();
p.doReload();I am developing a new plugin where it need to modify the content of 'Execute Shell'. Above is my code. The above code 'seems' work fine because I see the content of 'Execute Shell' has been changed as expected. But the problem I met is although the content has been updated, jenkins still execute the old content from the temp 'sh' file(see as below).
[test] $ sh -xe C:\Users\HZCHEN~1\AppData\Local\Temp\hudson1593723515622610306.sh
Does anyone know why Jenkins still execute the old commands from the temp file? How to tell Jenkins to execute my new 'Execute Shell'?