Quantcast

using nonCPS and xml builder

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

using nonCPS and xml builder

niristotle okram
Hi, 
i have forged the below pipeline workflow. The intent is to generate the XML file as a part of the pipeline and it will be used in the subsequent stages of the pipeline. I can invoke the pipeline successfully, but i dont find the XML generated in the workspace. I would expect the "file.XML" generated in the workspace. As you can see, i am not full fledge in groovy yet. 

How can i make sure that the file.xml is created in the workspace? If i execute the script ( without the class generateXML() )in a groovyconsole it works. 
Any idea on how to pass the values of the variable before triggering the job?

  def workflows = [
  [ name: 'A', file: 'fileA', objectName: 'wf_A', objectType: 'workflow', sourceRepository: 'DEV2', folderNames: [ multifolder: '{{multifolderTST}}', multifolder2: '{{multifolderTST2}}' ]],  [ name: 'B',
  file: 'fileB', objectName: 'wf_B',  objectType: 'workflow', sourceRepository: 'DEV2', folderNames: [ multifolder3: '{{multifolderTST3}}', multifolder4: '{{multifolderTST4}}' ]]
  ]



////////////////


import groovy.xml.*

node('linux') {

//clear workspace 
deleteDir()

  stage('Checkout') {
                //stuff to checkout
  }

  /*
  This will generate the manifest xml in the workspace of the running job
  */

generateXML()


}



@NonCPS

generateXML() {
  def workflows = [
  [ name: 'A', file: 'fileA', objectName: 'wf_A', objectType: 'workflow', sourceRepository: 'DEV2', folderNames: [ multifolder: '{{multifolderTST}}', multifolder2: '{{multifolderTST2}}' ]],  [ name: 'B',
  file: 'fileB', objectName: 'wf_B',  objectType: 'workflow', sourceRepository: 'DEV2', folderNames: [ multifolder3: '{{multifolderTST3}}', multifolder4: '{{multifolderTST4}}' ]]
  ]

  def writer = new FileWriter('file.xml')
  def builder = new StreamingMarkupBuilder()
  builder.encoding = 'UTF-8'
  writer << builder.bind {
    mkp.xmlDeclaration()
    mkp.declareNamespace(udm :'http://www.w3.org/2001/XMLSchema')
    mkp.declareNamespace(powercenter:'http://www.w3.org/2001/XMLSchema')
    delegate.udm.DeploymentPackage(version:'$BUILD_NUMBER', application: "informaticaApp"){
      delegate.deployables {
        workflows.each { item ->
          delegate.powercenter.PowercenterXml(name:item.name, file:item.file) {
            delegate.scanPlaceholders(true)
            delegate.sourceRepository(item.sourceRepository)
            delegate.folderNameMap {
              item.folderNames.each { name, value ->
                it.entry(key:name, value)
              }
            }
            delegate.objectNames {
              delegate.value(item.objectName)
            }
            delegate.objectTypes {
              delegate.value(item.objectType)
            }
          }
        }
      }
      delegate.dependencyResolution('LATEST')
      delegate.undeployDependencies(false)
    }
  }
}








--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPzcO4hy8KR-4MXokdyTUTw4PrHUUkBtDEq%2BAaQvjmxo%2BN9ZPA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...