Skip to content

Commit

Permalink
Change import_objects to generate a BASH script instead of pmrep comm…
Browse files Browse the repository at this point in the history
…and file (#37)

* Changed import_objects.groovy to generate bash script instead of pmrep command file.

* Fixed code left behind to look at lastLine of output file
  • Loading branch information
suranc authored and Nick Mathison committed Jan 10, 2018
1 parent 930a903 commit f1eaf81
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 37 deletions.
3 changes: 3 additions & 0 deletions plugin/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,8 @@ Added Folder Migration and Validate Folder Migration steps.
<release-note plugin-version="28">
Added a new step - "Deploy Multiple Deployment Groups"
</release-note>
<release-note plugin-version="29">
Modified import_objects.groovy to run pmrep commands one at a time in a bash script, instead of passing pmrep a command file.
</release-note>
</release-notes>
</pluginInfo>
2 changes: 1 addition & 1 deletion plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<identifier version="28" id="com.urbancode.air.plugin.Informatica" name="Informatica"/>
<identifier version="29" id="com.urbancode.air.plugin.Informatica" name="Informatica"/>
<description>
The Informatica plugin is an automation based plugin. It is executed as part of the deployment to migrate Informatica configuration and run scripts against the Informatica server and for creating and deploying deploying groups.
</description>
Expand Down
2 changes: 2 additions & 0 deletions plugin/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,6 @@
<migrate-command name="Deploy Multiple Deployment Groups">
</migrate-command>
</migrate>
<migrate to-version="29">
</migrate>
</plugin-upgrade>
58 changes: 22 additions & 36 deletions src/main/scripts/import_objects.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ final def conflictResolutionDefault = stepProps['conflictResolutionDefault'];
final def retainGenSeq = Boolean.valueOf(stepProps['retainGenSeq']);
final def checkinAfterImport = Boolean.valueOf(stepProps['checkinAfterImport']);

final def inputFile = 'informatica_script.' + unique + '.in'
final def outputFile = 'informatica_script.' + unique + '.out'
final def inputFile = 'informatica_script.' + unique + '.sh'
final def controlFile = 'informatica_script.' + unique + '.ctl'

final def conflictRuleSet = [
Expand Down Expand Up @@ -112,9 +111,21 @@ else {
fileSet << [(newXmlFile) : "${oldFileName}.xml"]
}

// generate Informatica script
// generate Bash script with pmrep Informatica commands
def script = new File(workDir, inputFile)
script.deleteOnExit()
script.deleteOnExit()

script << "#!/bin/bash $LS";

script.setExecutable(true);

if (infaHome != null && infaHome != "") {
script << infaHome + File.separator + "server" + File.separator + "bin" + File.separator + "pmrep ";
}
else {
script << 'pmrep ';
}

script << "connect -r $repo -n $username -x $password "

if (securityDomain){
Expand All @@ -129,11 +140,16 @@ else {
}

fileSet.keySet().each {
if (infaHome != null && infaHome != "") {
script << infaHome + File.separator + "server" + File.separator + "bin" + File.separator + "pmrep ";
}
else {
script << 'pmrep ';
}
def filePrefix = it.name.substring(0, it.name.indexOf(".xml"))
script << "ObjectImport -i \"$it\" -c \"${filePrefix}.ctl\" $LS"
}

script << "exit"
println('script content:')
script.eachLine { line -> println(line) }
println('')
Expand Down Expand Up @@ -251,19 +267,7 @@ else {

//run the Informatica command
def command = []
if (infaHome != null && infaHome != "") {
command.add(infaHome + File.separator + "server" + File.separator + "bin" + File.separator + "pmrep");
}
else {
command.add('pmrep')
}
command.add('run')
command.add('-o')
command.add(outputFile)
command.add('-f')
command.add(inputFile)
command.add('-e')
command.add('-s')

println('command:')
println(command.join(' '))
Expand Down Expand Up @@ -308,25 +312,7 @@ else {
process.getOutputStream().close() // close stdin
process.waitFor()

def output = new File(workDir, outputFile)
Scanner sc = new Scanner(output)
println('pmrep output:')
def lastLine = ""
while (sc.hasNextLine()) {
lastLine = sc.nextLine()
println(lastLine)
}
println('')
sc.close()

output.delete()

if (!lastLine || !lastLine.trim().equalsIgnoreCase("exit")) {
exitCode = 1
}
else {
exitCode = process.exitValue()
}
exitCode = process.exitValue();
}
catch (Exception ex) {
println "[Error] Please review the output log and stack trace for information on the error."
Expand Down

0 comments on commit f1eaf81

Please sign in to comment.