Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where properties section will completely removed in config xml. #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/main/groovy/com/neoteric/jenkins/JenkinsApi.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,14 @@ class JenkinsApi {
startOnCreateParam.parent().remove(startOnCreateParam)
}

//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]

if (!parameterDefinitionsProperty.attributes() && !parameterDefinitionsProperty.children() && !parameterDefinitionsProperty.text()) {
root.remove(propertiesNode)
new Node(root, 'properties')
}

//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 parameterDefinitions = propertiesNode."hudson.model.ParametersDefinitionProperty"
def parameterDefinitionsProperty = parameterDefinitions.parameterDefinitions[0]

if(!parameterDefinitionsProperty.attributes() && !parameterDefinitionsProperty.children() && !parameterDefinitionsProperty.text()) {
parameterDefinitions.replaceNode{}
}

def writer = new StringWriter()
XmlNodePrinter xmlPrinter = new XmlNodePrinter(new PrintWriter(writer))
Expand Down