How to Submit a Setup From Within a Setup

Follow

This script can be used to submit a setup from within a setup using a JAMS job.  The job will wait for the setup it submits to complete, and return an error if it fails. 

  

### Import JAMS module and define JAMS server
Import-Module JAMS
$JAMSDefaultServer = "localhost"

### Submit the setup
$entryid = Submit-JAMSEntry -Name "SetupName"

### Get the setup we just submitted
$entry = Get-JAMSEntry -Entry $entryid.JAMSEntry

### Wait for it...
Wait-JAMSEntry $entry

### Write the final status of the setup we submitted
Write-Host "Final Status of entry " $entry.JAMSentry "is" $entry.FinalSeverity

### If the setup failed, we fail the job that submits it, so the setup this job is in behaves as expected
If($entry.FinalSeverity -ne "Success"){

Throw "The child Setup has failed!"

}

   

Have more questions? Submit a request

Comments

  • Avatar
    Jared Stroebele

    $JAMSDefaultServer does not appear to be used. What is the purpose of making the assignment? if we are running the PowerShell Job in JAMS do we not have to use New-PSDrive?

    Edited by Jared Stroebele
  • Avatar
    Gennaro Piccolo

    Jared, a PS Drive is only needed if you will be getting an object from within the JAMS folder structure. In this case, $JAMSDefaultServer is used to define the JAMS Server to use when executing the submit-jamsentry and wait-jamsentry commands.

    The setup name is hard coded in this case, or the name of the setup could be gathered from another part of the script (using a PS Drive), but that is not included in this example.