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.
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()
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)
}
}
}