I would like to have my plugin to schedule a new builds in specific project, from another project/build. And at the same time provide a few variables to a new build.
I have a classes that implements SimpleBuildStep and Builder that should do the scheduling logic. I managed to find the Job where I would like to schedule the new build, but then I couldn't figure out that to do next. public class StartNewBuildStep extends NewBuild implements SimpleBuildStep { @Override public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { super.perform(run, workspace, listener); } } public class NewBuild extends Builder { void perform(Run<?, ?> run, FilePath workspace, TaskListener listener) throws AbortException { // Doing interesting stuff, and collect stuff for params list List<String> params; Jenkins jenkinsInstance = Jenkins.getInstanceOrNull(); if (jenkinsInstance != null) { // Job.class fetches both freestyle (Project.class) projects and pipelines (WorkflowJob.class) List<Job> projects = jenkinsInstance.getAllItems(Job.class); for (Job job : projects) { // name is later provided by the user if (job.getDisplayName().equals("test_project_pipeline")) { // What to do next? for (String param : params) { // TODO/help needed modify the build and schedule new build with param. } } } } } } test_project_pipeline's pipeline script is something that the users will configure by themselves, pipeline script would look something like this: node ("master"){ stage ("example"){ somePlugin param1: '$param', param2: 'foo' } // + other stages } So StartNewBuildStep's idea would be that it modifies the* $param* value from the pipeline script or somehow provides it. Then it would schedule the new build with the new params. StartNewBuildStep can schedule several builds at once for test_project_pipeline project, always with different params. Is this idea possible, if so, then how to continue? Do I have to take account the fact that there can be a freestyle and pipeline projects? -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e7152722-9b70-422d-84a4-dea6cc013aff%40googlegroups.com.