diff --git a/src/main/java/io/alauda/jenkins/devops/sync/constants/Constants.java b/src/main/java/io/alauda/jenkins/devops/sync/constants/Constants.java index 41660437..f9711138 100644 --- a/src/main/java/io/alauda/jenkins/devops/sync/constants/Constants.java +++ b/src/main/java/io/alauda/jenkins/devops/sync/constants/Constants.java @@ -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"; diff --git a/src/main/java/io/alauda/jenkins/devops/sync/input/AlaudaInputExtension.java b/src/main/java/io/alauda/jenkins/devops/sync/input/AlaudaInputExtension.java index c4c2169b..e8283fc7 100644 --- a/src/main/java/io/alauda/jenkins/devops/sync/input/AlaudaInputExtension.java +++ b/src/main/java/io/alauda/jenkins/devops/sync/input/AlaudaInputExtension.java @@ -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()); } @@ -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 paramValueParserIt = Jenkins.getInstance() .getExtensionList(ParamValueParser.class).iterator(); InputRequest inputRequest = InputStepConvert.convert(input, paramValueParserIt); inputRequest.setBuildID(buildID); + inputRequest.setBaseURI(baseURI); jsonArray.add(inputRequest); return jsonArray; diff --git a/src/main/java/io/alauda/jenkins/devops/sync/model/InputRequest.java b/src/main/java/io/alauda/jenkins/devops/sync/model/InputRequest.java index 63d3e112..2b6d406e 100644 --- a/src/main/java/io/alauda/jenkins/devops/sync/model/InputRequest.java +++ b/src/main/java/io/alauda/jenkins/devops/sync/model/InputRequest.java @@ -9,6 +9,7 @@ public class InputRequest { private String submitter; private List params; private String status; + private String baseURI; public String getId() { return id; @@ -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; + } } diff --git a/src/main/java/io/alauda/jenkins/devops/sync/watcher/PipelineWatcher.java b/src/main/java/io/alauda/jenkins/devops/sync/watcher/PipelineWatcher.java index 84166fda..d888b086 100644 --- a/src/main/java/io/alauda/jenkins/devops/sync/watcher/PipelineWatcher.java +++ b/src/main/java/io/alauda/jenkins/devops/sync/watcher/PipelineWatcher.java @@ -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; @@ -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; /** @@ -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 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) diff --git a/src/test/java/io/alauda/jenkins/devops/sync/util/DevOpsInit.java b/src/test/java/io/alauda/jenkins/devops/sync/util/DevOpsInit.java index 729d5630..d0edc031 100644 --- a/src/test/java/io/alauda/jenkins/devops/sync/util/DevOpsInit.java +++ b/src/test/java/io/alauda/jenkins/devops/sync/util/DevOpsInit.java @@ -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()