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

Advanced XML manipulation #71

Open
realdadfish opened this issue Jan 26, 2016 · 0 comments
Open

Advanced XML manipulation #71

realdadfish opened this issue Jan 26, 2016 · 0 comments

Comments

@realdadfish
Copy link
Contributor

I have an XML template that contains a single publisher XML snippet that I want to dynamically expand to multiple instances of the same snippet, but of course with different configuration for each.

While I figured out that I can easily add new nodes via the leftShift operator on the projectXml, I don't seem to be able to override the child elements of the just copied nodes, because they're not yet visible.

I came up with the following workaround, but I found that rather ugly:

jenkins {
    templates {
        hockeyupload_bare {
            xml file('path/to/hockeyupload.xml')
        }
        hockeyupload_multiplied {
            xml jenkins.templates.hockeyupload_bare.override { projectXml ->
                if (project.ext.hockeyAppIds.size() > 1) {
                    (1..project.ext.hockeyAppIds.size() - 1).each {
                        projectXml.publishers << projectXml.publishers["hockeyapp.HockeyappRecorder"]
                    }
                }
            }
        }
        hockeyupload {
            xml templates.hockeyupload_multiplied.override { projectXml ->
                def item = 0
                project.ext.hockeyAppIds.each { hockeyAppid ->
                    projectXml.publishers["hockeyapp.HockeyappRecorder"][item].applications["hockeyapp.HockeyappApplication"].with {
                        // specific overrides ..
                    }
                    ++item
                }
            }
        }
    }
}

Am I missing something or should this plugin somehow gain "flush" support to avoid these kind of hacks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant