Skip to content

Commit

Permalink
set pruneDeadBranches to false when without discarder
Browse files Browse the repository at this point in the history
  • Loading branch information
yudong2015 authored and ks-ci-bot committed Nov 6, 2023
1 parent 67d7eaf commit 3bdbe03
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/client/devops/jenkins/pipeline_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,15 @@ func createMultiBranchPipelineConfigXml(projectName string, pipeline *devopsv1al
appendMultiBranchJobTriggerToEtree(properties, pipeline.MultiBranchJobTrigger)
}

discarder := project.CreateElement("orphanedItemStrategy")
discarder.CreateAttr("class", "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy")
discarder.CreateAttr("plugin", "cloudbees-folder")
if pipeline.Discarder != nil {
discarder := project.CreateElement("orphanedItemStrategy")
discarder.CreateAttr("class", "com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy")
discarder.CreateAttr("plugin", "cloudbees-folder")
discarder.CreateElement("pruneDeadBranches").SetText("true")
discarder.CreateElement("daysToKeep").SetText(pipeline.Discarder.DaysToKeep)
discarder.CreateElement("numToKeep").SetText(pipeline.Discarder.NumToKeep)
} else {
discarder.CreateElement("pruneDeadBranches").SetText("false")
}

triggers := project.CreateElement("triggers")
Expand Down Expand Up @@ -525,9 +527,11 @@ func parseMultiBranchPipelineConfigXml(config string) (*devopsv1alpha3.MultiBran
}

if discarder := project.SelectElement("orphanedItemStrategy"); discarder != nil {
pipeline.Discarder = &devopsv1alpha3.DiscarderProperty{
DaysToKeep: getElementTextValueOrEmpty(discarder, "daysToKeep"),
NumToKeep: getElementTextValueOrEmpty(discarder, "numToKeep"),
if getElementTextValueOrEmpty(discarder, "pruneDeadBranches") == "true" {
pipeline.Discarder = &devopsv1alpha3.DiscarderProperty{
DaysToKeep: getElementTextValueOrEmpty(discarder, "daysToKeep"),
NumToKeep: getElementTextValueOrEmpty(discarder, "numToKeep"),
}
}
}
if triggers := project.SelectElement("triggers"); triggers != nil {
Expand Down

0 comments on commit 3bdbe03

Please sign in to comment.