Skip to content

Commit 98d306c

Browse files
committed
JENKINS-57117 - support pipeline jobs
1 parent c3cd258 commit 98d306c

File tree

9 files changed

+34
-3
lines changed

9 files changed

+34
-3
lines changed

pom.xml

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ THE SOFTWARE.
2727
<parent>
2828
<groupId>org.jenkins-ci.plugins</groupId>
2929
<artifactId>plugin</artifactId>
30-
<version>1.424</version>
30+
<version>3.51</version> <!-- or whatever the newest version available is -->
3131
</parent>
3232

3333
<artifactId>scripttrigger</artifactId>
@@ -52,6 +52,8 @@ THE SOFTWARE.
5252
</developers>
5353

5454
<properties>
55+
<jenkins.version>2.176.1</jenkins.version>
56+
<java.level>8</java.level>
5557
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5658
<maven.compiler.source>1.6</maven.compiler.source>
5759
<maven.compiler.target>1.6</maven.compiler.target>

src/main/java/org/jenkinsci/plugins/scripttrigger/ScriptTriggerExecutor.java

100644100755
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import hudson.tasks.CommandInterpreter;
3333
import hudson.tasks.Shell;
3434
import org.jenkinsci.lib.xtrigger.XTriggerLog;
35+
import org.jenkinsci.remoting.RoleChecker;
3536

3637
import java.io.*;
3738
import java.util.Map;
@@ -78,6 +79,9 @@ protected String getStringContent(Node executingNode, final String filePath) thr
7879

7980
try {
8081
return executingNode.getRootPath().act(new FilePath.FileCallable<String>() {
82+
@Override
83+
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
84+
}
8185

8286
public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
8387
StringBuffer content = new StringBuffer();
@@ -106,6 +110,10 @@ private int executeScript(final Node executingNode, final String scriptContent,
106110
try {
107111

108112
boolean isUnix = executingNode.getRootPath().act(new Callable<Boolean, ScriptTriggerException>() {
113+
@Override
114+
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
115+
}
116+
109117
public Boolean call() throws ScriptTriggerException {
110118
return File.pathSeparatorChar == ':';
111119
}
@@ -125,6 +133,10 @@ public Boolean call() throws ScriptTriggerException {
125133
throw new ScriptTriggerException("The node is offline.");
126134
}
127135
return rootPath.act(new FilePath.FileCallable<Integer>() {
136+
@Override
137+
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
138+
}
139+
128140
public Integer invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
129141
try {
130142
return getLocalLauncher(log.getListener()).launch().cmds(cmd).envs(envVars).stdout(log.getListener()).pwd(rootPath).join();
@@ -159,6 +171,10 @@ private Launcher getLocalLauncher(TaskListener listener) throws ScriptTriggerExc
159171
protected boolean existsScript(Node executingNode, final String path) throws ScriptTriggerException {
160172
try {
161173
return executingNode.getRootPath().act(new Callable<Boolean, ScriptTriggerException>() {
174+
@Override
175+
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
176+
}
177+
162178
public Boolean call() throws ScriptTriggerException {
163179
File f = new File(path);
164180
if (!f.exists()) {

src/main/java/org/jenkinsci/plugins/scripttrigger/groovy/GroovyScriptTrigger.java

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import hudson.model.*;
3131
import hudson.remoting.VirtualChannel;
3232
import hudson.security.ACL;
33+
import jenkins.model.Jenkins;
3334
import org.acegisecurity.Authentication;
3435
import org.acegisecurity.context.SecurityContextHolder;
3536
import org.apache.commons.jelly.XMLOutput;
@@ -40,6 +41,7 @@
4041
import org.jenkinsci.plugins.scripttrigger.AbstractTrigger;
4142
import org.jenkinsci.plugins.scripttrigger.LabelRestrictionClass;
4243
import org.jenkinsci.plugins.scripttrigger.ScriptTriggerException;
44+
import org.jenkinsci.remoting.RoleChecker;
4345
import org.kohsuke.stapler.DataBoundConstructor;
4446

4547
import java.io.File;
@@ -48,8 +50,6 @@
4850
import java.nio.charset.Charset;
4951
import java.util.*;
5052

51-
import jenkins.model.Jenkins;
52-
5353

5454
/**
5555
* @author Gregory Boissinot
@@ -127,6 +127,9 @@ protected Action[] getScheduledActions(Node pollingNode, final XTriggerLog log)
127127
throw new ScriptTriggerException("The node is offline.");
128128
}
129129
return rootPath.act(new FilePath.FileCallable<Action[]>() {
130+
@Override
131+
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
132+
}
130133

131134
public Action[] invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
132135
File propFile = new File(propertiesFilePath);

src/main/java/org/jenkinsci/plugins/scripttrigger/groovy/GroovyScriptTriggerExecutor.java

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.jenkinsci.lib.xtrigger.XTriggerLog;
3434
import org.jenkinsci.plugins.scripttrigger.ScriptTriggerException;
3535
import org.jenkinsci.plugins.scripttrigger.ScriptTriggerExecutor;
36+
import org.jenkinsci.remoting.RoleChecker;
3637

3738
import java.io.File;
3839
import java.io.FileInputStream;
@@ -60,6 +61,10 @@ public boolean evaluateGroovyScript(Node executingNode, final AbstractProject pr
6061
}
6162

6263
return executingNode.getRootPath().act(new Callable<Boolean, ScriptTriggerException>() {
64+
@Override
65+
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
66+
}
67+
6368
public Boolean call() throws ScriptTriggerException {
6469
log.info("Running as node script");
6570
return evaluateGroovyScript(null, scriptContent, envVars);

src/main/resources/index.jelly

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?jelly escape-by-default='true'?>
12
<div>
23
This plugin makes it possible to poll changes of an environment with a script.
34
</div>

src/main/resources/org/jenkinsci/plugins/scripttrigger/ScriptTrigger/config.jelly

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?jelly escape-by-default='true'?>
12
<!--
23
The MIT License (MIT)
34

src/main/resources/org/jenkinsci/plugins/scripttrigger/ScriptTriggerAction/index.jelly

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?jelly escape-by-default='true'?>
12
<!--
23
The MIT License
34

src/main/resources/org/jenkinsci/plugins/scripttrigger/groovy/GroovyScriptTrigger/config.jelly

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?jelly escape-by-default='true'?>
12
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
23

34
<f:entry field="groovySystemScript" title="${%Groovy System Script}">

src/main/resources/org/jenkinsci/plugins/scripttrigger/groovy/GroovyScriptTriggerAction/index.jelly

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?jelly escape-by-default='true'?>
12
<!--
23
The MIT License
34

0 commit comments

Comments
 (0)