27
27
import hudson.ExtensionListView;
28
28
import hudson.Extension;
29
29
import hudson.ExtensionList;
30
import hudson.FilePath;
31
import hudson.Launcher;
32
import hudson.model.AbstractBuild;
33
import hudson.model.BuildListener;
34
import hudson.model.Environment;
35
import hudson.model.JobProperty;
30
36
import hudson.model.Run;
31
37
import hudson.model.TaskListener;
32
import hudson.model.Hudson;
38
import jenkins.model.Jenkins;
39
import hudson.scm.SCM;
40
import hudson.tasks.BuildWrapper;
33
41
import hudson.util.CopyOnWriteList;
34
42
import org.jvnet.tiger_types.Types;
45
import java.io.IOException;
36
46
import java.lang.reflect.ParameterizedType;
37
47
import java.lang.reflect.Type;
98
108
public void onStarted(R r, TaskListener listener) {}
111
* Runs before the {@link SCM#checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)} runs, and performs a set up.
112
* Can contribute additional properties/env vars to the environment.
115
* A typical strategy is for implementations to check {@link JobProperty}s and other configuration
116
* of the project to determine the environment to inject, which allows you to achieve the equivalent of
117
* {@link BuildWrapper}, but without UI.
120
* The build in progress for which an {@link Environment} object is created.
123
* This launcher can be used to launch processes for this build.
124
* If the build runs remotely, launcher will also run a job on that remote machine.
127
* Can be used to send any message.
129
* non-null if the build can continue, null if there was an error
130
* and the build needs to be aborted.
131
* @throws IOException
132
* terminates the build abnormally. Hudson will handle the exception
133
* and reports a nice error message.
136
public Environment setUpEnvironment( AbstractBuild build, Launcher launcher, BuildListener listener ) throws IOException, InterruptedException {
137
return new Environment() {};
101
141
* Called right before a build is going to be deleted.
103
143
* @param r The build.
130
170
public static final CopyOnWriteList<RunListener> LISTENERS = ExtensionListView.createCopyOnWriteList(RunListener.class);
133
* Fires the {@link #onCompleted} event.
173
* Fires the {@link #onCompleted(Run, TaskListener)} event.
135
175
public static void fireCompleted(Run r, TaskListener listener) {
136
176
for (RunListener l : all()) {
143
* Fires the {@link #onStarted} event.
183
* Fires the {@link #onStarted(Run, TaskListener)} event.
145
185
public static void fireStarted(Run r, TaskListener listener) {
146
186
for (RunListener l : all()) {
173
213
* Returns all the registered {@link RunListener} descriptors.
175
215
public static ExtensionList<RunListener> all() {
176
return Hudson.getInstance().getExtensionList(RunListener.class);
216
return Jenkins.getInstance().getExtensionList(RunListener.class);