Remove XML tags

32 views
Skip to first unread message

Christian Rasp

unread,
Aug 5, 2015, 5:09:21 AM8/5/15
to job-dsl-plugin
Hi,


we are trying to find a way to remove certain XML tags, after they were created.

For example, this works fine:

job('remove-all-publishers') {
  publishers {
    deployArtifacts()
    archiveJunit('**/target/**/*.xml')
  }
  configure { Node project ->
    Node publishers = project / publishers
    if (publishers) {
      project.remove(publishers)
    }
  }
}

But on the next level, this won't work anymore:

job('remove-only-test-result-publishing') {
  publishers {
    deployArtifacts()
    archiveJunit('**/target/**/*.xml')
  }
  configure { Node project ->
    Node publishTest = project / publishers / 'hudson.tasks.junit.JUnitResultArchiver'
    if (publishTest) {
      project.remove(publishTest)
    }
  }
}

Does the remove action only work for tags on the first level or am I missing something in the syntax?


Regards
Christian

Matt Sheehan

unread,
Aug 5, 2015, 10:04:00 AM8/5/15
to job-dsl-plugin
Hi Christian. You need to remove the node from its parent. Something like this should work:

(project / publishers).remove(publishTest)

or 

publishTest.parent().remove(publishTest)


--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/802ba3b7-b4b8-4223-94a3-bab95dc47bec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Rasp

unread,
Aug 6, 2015, 6:34:22 AM8/6/15
to job-dsl-plugin
Hi Matt,

thank you so much. This XML Node thingy is quite confusing :)
The following jobs are equivalent:
job('remove-test-result-publishing') {
  publishers {
    archiveJunit('**/target/**/*.xml')
  }
  configure { Node project ->
    Node publishTest = project / publishers / 'hudson.tasks.junit.JUnitResultArchiver'
    if (publishTest) {
      (project / publishers).remove(publishTest)
    }
  }
}

job('empty-job') {}


Reply all
Reply to author
Forward
0 new messages