This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enabling support for "Build Token Root "
“build token root” support is controled as a remote-host level (not job by job)
- Loading branch information
Showing
5 changed files
with
39 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,10 @@ | |
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
@@ -36,7 +38,6 @@ public class RemoteBuildConfiguration extends Builder { | |
private final String token; | ||
private final String remoteJenkinsName; | ||
private final String job; | ||
private final boolean buildTokenRootEnabled; | ||
// "parameters" is the raw string entered by the user | ||
private final String parameters; | ||
// "parameterList" is the cleaned-up version of "parameters" (stripped out comments, character encoding, etc) | ||
|
@@ -56,7 +57,6 @@ public RemoteBuildConfiguration(String remoteSites, String job, String token, St | |
this.remoteJenkinsName = remoteSites; | ||
this.parameters = parameters; | ||
this.job = job.trim(); | ||
this.buildTokenRootEnabled = false; | ||
|
||
// split the parameter-string into an array based on the new-line character | ||
String[] params = parameters.split("\n"); | ||
|
@@ -165,10 +165,11 @@ private void addToQueryString(String item) { | |
} | ||
|
||
private String buildTriggerUrl() { | ||
String triggerUrlString = this.findRemoteHost(this.getRemoteJenkinsName()).getAddress().toString(); | ||
RemoteJenkinsServer remoteServer = this.findRemoteHost(this.getRemoteJenkinsName()); | ||
|
||
if (this.getbuildTokenRootEnabled()) { | ||
// if (true) { | ||
String triggerUrlString = remoteServer.getAddress().toString(); | ||
|
||
if (remoteServer.getHasBuildTokenRootSupport()) { | ||
triggerUrlString += buildTokenRootUrl; | ||
triggerUrlString += paramerizedBuildUrl; | ||
|
||
|
@@ -186,6 +187,8 @@ private String buildTriggerUrl() { | |
|
||
this.addToQueryString(this.getParameters(true)); | ||
|
||
this.addToQueryString("delay=0"); | ||
|
||
triggerUrlString += "?" + this.getQueryString(); | ||
|
||
return triggerUrlString; | ||
|
@@ -221,21 +224,21 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListener lis | |
// - http://jenkins.local/job/test/lastBuild/api/json | ||
|
||
InputStream is = connection.getInputStream(); | ||
/* | ||
|
||
BufferedReader rd = new BufferedReader(new InputStreamReader(is)); | ||
String line; | ||
StringBuffer response = new StringBuffer(); | ||
//String line; | ||
//StringBuffer response = new StringBuffer(); | ||
|
||
while ((line = rd.readLine()) != null) { | ||
System.out.println(line); | ||
} | ||
rd.close(); | ||
*/ | ||
//while ((line = rd.readLine()) != null) { | ||
//System.out.println(line); //JSONObject r = new | ||
|
||
//} | ||
//rd.close(); | ||
|
||
} catch (IOException e) { | ||
// something failed with the connection, so throw an exception to mark the build as failed. | ||
e.printStackTrace(); | ||
throw new AbortException("Faield to oppen conenction to the remote server."); | ||
throw new AbortException(e.getMessage()); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
morficus
Author
Owner
|
||
} finally { | ||
// always make sure we close the connection | ||
if (connection != null) { | ||
|
@@ -275,10 +278,6 @@ public String getParameters() { | |
return this.parameters; | ||
} | ||
|
||
public boolean getbuildTokenRootEnabled() { | ||
return this.buildTokenRootEnabled; | ||
} | ||
|
||
public String getQueryString() { | ||
return this.queryString; | ||
} | ||
|
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
10 changes: 10 additions & 0 deletions
10
...plugins/ParameterizedRemoteTrigger/RemoteJenkinsServer/help-hasBuildTokenRootSupport.html
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,10 @@ | ||
<div> | ||
<div style="font-weight: bolder; text-decoration: underline"> | ||
Build Token Root | ||
</div> | ||
If your remote Jenkins host has the | ||
<a href="https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin" target="_blank"> | ||
"Build Token Root" plugin" | ||
</a> | ||
installed, then you will want to enable this option. | ||
</div> |
An option to make this build step 'optional' (i.e. don't fail the build if this step fails) would be great.