Skip to content

Commit

Permalink
Add baseURI into input request model
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Apr 23, 2019
1 parent c6c5378 commit e1603ae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ private Constants(){}
public static final String ALAUDA_DEVOPS_ANNOTATIONS_JENKINS_IDENTITY = "alauda.io/jenkins-instance-identity";

public static final String ALAUDA_DEVOPS_ANNOTATIONS_JENKINS_INPUT_REQUESTS = "alauda.io/jenkins-input-requests";
public static final String ALAUDA_DEVOPS_ANNOTATIONS_JENKINS_INPUT_RESPONSES = "alauda.io/jenkins-input-responses";

/** secret keys */
public static final String ALAUDA_DEVOPS_SECRETS_DATA_USERNAME = "username";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ private void addInputRequest(InputStep input, Run run) {
String namespace = targetPipeline.getMetadata().getNamespace();
String name = targetPipeline.getMetadata().getName();

String buildID = run.getId();
JSONArray jsonArray = getAndAddRequestJson(targetPipeline, input, buildID);
JSONArray jsonArray = getAndAddRequestJson(targetPipeline, input, run);
updatePipeline(namespace, name, jsonArray.toString());
}

Expand Down Expand Up @@ -153,14 +152,17 @@ private JSONArray getRequestJson(Pipeline targetPipeline) {
return jsonArray;
}

private JSONArray getAndAddRequestJson(Pipeline targetPipeline, InputStep input, String buildID) {
private JSONArray getAndAddRequestJson(Pipeline targetPipeline, InputStep input, Run run) {
JSONArray jsonArray = getRequestJson(targetPipeline);
String buildID = run.getId();
String baseURI = run.getUrl();

Iterator<ParamValueParser> paramValueParserIt = Jenkins.getInstance()
.getExtensionList(ParamValueParser.class).iterator();

InputRequest inputRequest = InputStepConvert.convert(input, paramValueParserIt);
inputRequest.setBuildID(buildID);
inputRequest.setBaseURI(baseURI);
jsonArray.add(inputRequest);

return jsonArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class InputRequest {
private String submitter;
private List<InputRequestParam> params;
private String status;
private String baseURI;

public String getId() {
return id;
Expand Down Expand Up @@ -57,4 +58,12 @@ public String getStatus() {
public void setStatus(String status) {
this.status = status;
}

public String getBaseURI() {
return baseURI;
}

public void setBaseURI(String baseURI) {
this.baseURI = baseURI;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import io.alauda.kubernetes.client.Watcher;
import jenkins.model.Jenkins;
import jenkins.security.NotReallyRoleSensitiveCallable;
import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand All @@ -44,7 +42,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static io.alauda.jenkins.devops.sync.constants.Constants.ALAUDA_DEVOPS_ANNOTATIONS_JENKINS_INPUT_RESPONSES;
import static java.util.logging.Level.SEVERE;

/**
Expand Down Expand Up @@ -257,25 +254,6 @@ private static void modifyEventToJenkinsJobRun(Pipeline pipeline) {
// see if any pre-BC cached builds can now be flushed
flushPipelinesWithNoPCList();
}
//
// // handle the annotations
// Map<String, String> annotations = pipeline.getMetadata().getAnnotations();
// if(annotations == null || !annotations.containsKey(ALAUDA_DEVOPS_ANNOTATIONS_JENKINS_INPUT_RESPONSES)) {
// return;
// }
//
// String inputResponseJsonText = annotations.get(ALAUDA_DEVOPS_ANNOTATIONS_JENKINS_INPUT_RESPONSES);
// if(StringUtils.isEmpty(inputResponseJsonText)) {
// return;
// }
//
// try {
// JSONArray inputResponse = JSONArray.fromObject(inputResponseJsonText);
//
//// inputResponse.get
// } catch (JSONException e) {
// logger.warning(String.format("Cannot parse json array text: %s", inputResponseJsonText));
// }
}

public static synchronized boolean addEventToJenkinsJobRun(Pipeline pipeline)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public JenkinsBinding createBinding(AlaudaDevOpsClient client) {
public Jenkins createJenkins(AlaudaDevOpsClient client) {
String fakeUrl = "http://abc-"+System.nanoTime()+".com";
JenkinsSpec jenkinsSpec = new JenkinsSpecBuilder()
.withNewHttp(fakeUrl, fakeUrl)
.withNewHttp(fakeUrl)
.build();

return client.jenkins().createNew().withNewMetadata()
Expand Down

0 comments on commit e1603ae

Please sign in to comment.