Append new pipeline to 'view listing sections' using Job DSL - Jenkins

225 views Asked by At

Below is the config.xml for sectioned view plugin for section "View Listing Sections"

<hudson.plugins.sectioned__view.SectionedView plugin="[email protected]">
  <owner class="hudson" reference="../../.."/>
  <name>pipeline view</name>
  <filterExecutors>false</filterExecutors>
  <filterQueue>false</filterQueue>
  <properties class="hudson.model.View$PropertyList"/>
  <sections>
    <hudson.plugins.sectioned__view.ViewListingSection>
      <jobNames>
        <comparator class="hudson.util.CaseInsensitiveComparator"/>
      </jobNames>
      <jobFilters/>
      <name></name>
      <width>FULL</width>
      <alignment>CENTER</alignment>
      <views>
        <string>pipeline1</string>
        <string>pipeline2</string>
      </views>
      <columns>1</columns>
    </hudson.plugins.sectioned__view.ViewListingSection>
  </sections>
</hudson.plugins.sectioned__view.SectionedView>

I want to dynamically add a new pipeline view with name "pipeline3" to this config.xml and I am using Job DSL for the same. Below is the code which I have tried.

sectionedView('pipeline view') {
  configure { node ->
node / sections / 'hudson.plugins.sectioned__view.ViewListingSection'/ 'views' / string('pipeline3')
  }
}

The above code overrides the entire xml configuration instead of just appending a new value.

Can you please suggest me a solution for this. Thank you

1

There are 1 answers

1
daspilker On

Job DSL can only generate a complete view configuration. It can not update some parts of a view. You need to define the complete view configuration in Job DSL.