Create a Setup from all Jobs in a Folder

Follow

 

#
# This code example is intended to create a Setup in JAMS with all of the jobs
# Contained in our "Samples Folder." 
# It will define each step as 0, 1, 2, 3, etc
#

#
# Navigate to our JAMS drive - this is assuming you have already created
# A JAMS Drive within your PowerShell Profile if not please add the following:
NEW-PSDrive JD JAMS Localhost 

CD jd:

#
# Get the Setup
#
$setup = New-Item \Samples\MyNewSetup -ItemType 'Setup'

#
# Get the Jobs we want to add as SetupJobs
#
$jobs = GCI -ObjectType Job JD:\Samples\*
$x = 0

#
# Add the Jobs as SetupJobs to the Setup
#
ForEach($job in $jobs)
{
    $sj = New-Object "MVPSI.JAMS.SetupJob"
    $sj.JobName = $job.QualifiedName
    $sj.Step = $x++
    $setup.Jobs.Add($sj)
}

#
# Save the Setup
#
$setup.Update()

 

Have more questions? Submit a request

Comments

  • Avatar
    Dave Carnahan

    The article didn't define what a 'setup' is and how it is used, so a little confusing.
    But I see further down in the code 'setup' is the term for setting up a JAMS job...

    Also, the script could check for the existence of the JD drive (or JAMS provider) instead of documenting it, therefore self-fulfilling.

  • Avatar
    Louis Diaz

    Hello Dave,

    A Setup Definition allows you to link one or more Job definitions together so they can be run in sequence. The Setup can then be scheduled and JAMS will run the jobs in their sequential order, by default waiting for each child process to complete successfully before continuing through the flow. This allows for easier scheduling of multiple jobs.

    Here is an article that references some JAMS Terminology:
    https://support.jamsscheduler.com/hc/en-us/articles/216573098-JAMS-Terminology