-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1075 from daspilker/JENKINS-44256
[JENKINS-44256] enhanced support for the Groovy plugin
- Loading branch information
Showing
5 changed files
with
225 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/SystemGroovyCommandContext.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package javaposse.jobdsl.dsl.helpers.step | ||
|
||
import javaposse.jobdsl.dsl.DslScriptException | ||
import javaposse.jobdsl.dsl.JobManagement | ||
import javaposse.jobdsl.dsl.RequiresPlugin | ||
|
||
class SystemGroovyCommandContext extends SystemGroovyContext { | ||
private final JobManagement jobManagement | ||
|
||
boolean sandbox | ||
|
||
SystemGroovyCommandContext(JobManagement jobManagement) { | ||
this.jobManagement = jobManagement | ||
} | ||
|
||
/** | ||
* If set, run the Groovy script in a sandbox with limited abilities. Defaults to {@code false}. | ||
* | ||
* @since 1.67 | ||
*/ | ||
@RequiresPlugin(id = 'groovy', minimumVersion = '2.0') | ||
void sandbox(boolean sandbox = true) { | ||
this.sandbox = sandbox | ||
} | ||
|
||
@Override | ||
void classpath(String classpath) { | ||
if (jobManagement.isMinimumPluginVersionInstalled('groovy', '2.0')) { | ||
try { | ||
new URL(classpath) | ||
} catch (MalformedURLException e) { | ||
throw new DslScriptException("classpath must be a valid URL: ${e.message}") | ||
} | ||
} | ||
super.classpath(classpath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters