From b6a2142001ee3dd411b33875fe900f72c6391435 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 3 Feb 2016 22:11:12 +0100 Subject: [PATCH 1/3] fixed issue where always all properties where deleted. --- .../groovy/com/neoteric/jenkins/JenkinsApi.groovy | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy b/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy index 0c60b6a..90b3dca 100644 --- a/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy +++ b/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy @@ -89,6 +89,9 @@ class JenkinsApi { } public String processConfig(String entryConfig, String branchName, String gitUrl) { + println "----> entryConfig" + println entryConfig + def root = new XmlParser().parseText(entryConfig) // update branch name root.scm.branches."hudson.plugins.git.BranchSpec".name[0].value = "*/$branchName" @@ -101,7 +104,6 @@ class JenkinsApi { root.publishers."hudson.plugins.sonar.SonarPublisher".branch[0].value = "$branchName" } - //remove template build variable Node startOnCreateParam = findStartOnCreateParameter(root) if (startOnCreateParam) { @@ -110,14 +112,13 @@ class JenkinsApi { //check if it was the only parameter - if so, remove the enclosing tag, so the project won't be seen as build with parameters def propertiesNode = root.properties - def parameterDefinitionsProperty = propertiesNode."hudson.model.ParametersDefinitionProperty".parameterDefinitions[0] + def parameterDefinitions = propertiesNode."hudson.model.ParametersDefinitionProperty" + def parameterDefinitionsProperty = parameterDefinitions.parameterDefinitions[0] if(!parameterDefinitionsProperty.attributes() && !parameterDefinitionsProperty.children() && !parameterDefinitionsProperty.text()) { - root.remove(propertiesNode) - new Node(root, 'properties') + propertiesNode.remove(parameterDefinitions) } - def writer = new StringWriter() XmlNodePrinter xmlPrinter = new XmlNodePrinter(new PrintWriter(writer)) xmlPrinter.setPreserveWhitespace(true) From 4f9f42f697e851ff78841e989b3e3849022b41fb Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 3 Feb 2016 22:13:28 +0100 Subject: [PATCH 2/3] removed not necessary println command --- src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy b/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy index 90b3dca..0085214 100644 --- a/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy +++ b/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy @@ -89,9 +89,6 @@ class JenkinsApi { } public String processConfig(String entryConfig, String branchName, String gitUrl) { - println "----> entryConfig" - println entryConfig - def root = new XmlParser().parseText(entryConfig) // update branch name root.scm.branches."hudson.plugins.git.BranchSpec".name[0].value = "*/$branchName" From 7c33cc61e5015c27a953e04d51ce5f24afe0b5b7 Mon Sep 17 00:00:00 2001 From: Stefan Date: Thu, 3 Mar 2016 23:41:14 +0100 Subject: [PATCH 3/3] Actually remove parameter definitions node from properties node list. --- src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy b/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy index 0085214..db7f227 100644 --- a/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy +++ b/src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy @@ -113,7 +113,7 @@ class JenkinsApi { def parameterDefinitionsProperty = parameterDefinitions.parameterDefinitions[0] if(!parameterDefinitionsProperty.attributes() && !parameterDefinitionsProperty.children() && !parameterDefinitionsProperty.text()) { - propertiesNode.remove(parameterDefinitions) + parameterDefinitions.replaceNode{} } def writer = new StringWriter()