Using a Command Line to Deploy Jobs

Problem

You want to batch deploy or redeploy many jobs at once using a simple command-line interface.

Solution

You can use the command-line batch deployment tool to enable you to batch deploy or redeploy many jobs at once using a simple command-line interface. You invoke an executable named “DeployJobs.exe” and supply parameters to control its behavior. The BatchJobDeployment class retrieves the source code for each job. Then, it stores the code on the SAS Application Server that you specify and deploys the job on the specified server. All options are specified as arguments to the “DeployJobs” executable. Use other software to schedule the job for execution. For more information, see Scheduling in SAS.
The command-line batch deployment tool executes two distinct steps. First, it must generate the .SAS code for a job and save it to disk. Second, it must deploy the job’s generated .SAS code. Both of these steps require communication with the server and can affect performance in various ways. Currently, no method exists for you to determine how long the batch deployment might take or how close the batch process is to completion. As each job is processed, the application updates the log.
For each job specified by the user, at least one metadata object (a JFJob) will be created or modified. The only public method available to you within the com.sas.etl.migration.batch package is the main method of the BatchJobDeployment class. Program execution begins in this class.
Perform the following tasks:
Note: The batch deployment feature does not work when the host name contains a hyphen (-) character.
The command-line batch deployment tool is available at a location similar to the following: c:\program files\sashome\SASDataIntegrationStudioServerJars\4.8. The tool is named DeployJobs.exe. You should run the command-line deployment tool in the Microsoft Windows command window or in the interface appropriate to your operating system.

Tasks

Review the Prerequisites

In order to use the command-line tool to deploy jobs, you must meet the prerequisites described in Prerequisites for Deploying a Job for Scheduling. You must also gather server addresses, passwords, and other information that you need.

Review the Syntax for the Command-Line Batch Deployment Tool

DeployJobs
connection-options
-deploytype DEPLOY | REDEPLOY
-objects source-location-1 source-location-2 source-location-3 source-location-n
-sourcedir
-deploymentdir
-metarepository
-metaserverid
-appservername
-servermachine
-serverport
-serverusername
-serverpassword
-batchserver
-folder
-log LOG PATH| LOG PATH AND FILENAME
-recursive
-since FROM ABSOLUTE DATE | FROM RELATIVE DATE
-useauthdomain TRUE | FALSE

Review the Syntax Description for the Command-Line Batch Deployment Tool

connection-options

specifies connection options for the SAS Metadata Server from which the package is being deployed. See Specify Connection Options.

Requirement Required.

-deploytype DEPLOY | REDEPLOY

specifies the type of deployment. The following values are valid:

DEPLOY deploys jobs that have not already been deployed
REDEPLOY redeploys jobs that have already been deployed. Source code is regenerated and stored.

-objects source-location-1 source-location-2 source-location-3 ... source-location-n

specifies the locations of the jobs that are to be deployed. You can specify any number of locations. Leave a space between each location. If a location includes spaces, then enclose the location in quotation marks.

Use the following syntax to specify a location:
/folder-1/folder-2/...folder-n/<job name>
The following rules apply to specifying locations:
  • Locations are relative to the SAS Folders node. Therefore, the first folder that you specify in a location must be located directly beneath SAS Folders.
  • If you specify a folder but you do not specify a job name, then all jobs in that folder are deployed. If you specify the –recursive parameter, then all jobs in the specified folder and in folders beneath that folder will be deployed.
  • To deploy jobs from your personal folder, you must specify the actual path (/User Folders/user-name/My Folder or /Users/user-name/My Folder) rather than the shortcut (/My Folder). Note that the name of the parent folder for user folders varies depending on the SAS release in which the folders were created.
Here are some examples of locations:
  • -objects /
    This example deploys the entire SAS Folders hierarchy and all of its jobs.
  • -objects“/User Folders/sasdemo/My Folder" or -objects"/Users/sasdemo/My Folder"
    This example deploys all jobs that are in the personal folder of the user named sasdemo.
  • -objects"/Shared Data/Orion Star Data/Customer Orders"
    This example deploys the Customer Orders job, which is located in /Shared Data/Orion Star Data.
  • -objects"/Shared Data/Orion Star Data/Customer Orders" "/Shared Data/Orion Star Data/CUSTOMER_DIM" "/Shared Data/Orion Star Data/ORDER_FACT" "/Shared Reports/Orion Star Reports/Sales by Customer Type"
    This example deploys the Customer Orders job, the CUSTOMER_DIM job, and the ORDER_FACT job. These three jobs are located in /Shared Data/Orion Star Data. This example also deploys the Sales by Customer Type job, which is located in /Shared Reports/Orion Star Reports.
Requirement Required.

-sourcedir

the directory to store generated sas code. These files are deployed to the –deploymentdir location.

Requirement Required.

-deploymentdir

the deployment directory for the files containing the job’s code

Requirement Required for a deploy type. Optional for a redeploy.

-metarepository

the name of the metadata repository (for example, “Foundation”)

Requirement Required.

-metaserverid

the metadata ID of the SAS Application Server (for example, “A57CMFYM.AS000002”)

Requirement Optional.

-appservername

the name of ServerContext object (often"SASApp"). You can specify either -metaserverid or -appservername. If both are specified, -metaserverid is used.

Requirement Optional.
Note: The -metaserverid and -appservername arguments are both optional. However, you must specify one of these arguments whenever you run the command-line batch deployment tool. Do not specify both of these arguments for a single run.

-servermachine

the name of the machine that hosts the SAS Application Server

Requirement Required for a deploy type. Optional for a redeploy.

-serverport

the port for the SAS Application Server

Requirement Required for a deploy type. Optional for a redeploy.

-serverusername

the user ID to connect to the SAS Application Server

Requirement Optional. If not supplied, the user ID specified for the SAS Metadata Server is used.

-serverpassword

the password for the user ID used to connect to the SAS Application Server

Requirement Optional. If not supplied, the password specified for the SAS Metadata Server is used.

-batchserver

the name of the batch server component (for example, “SASApp – SAS DATA Step Batch Server”)

Requirement Required for a deploy type. Optional for a redeploy.

-folder

the folder location for the deployed job objects. If you specify a folder that does not exist with the -folder argument, then the deployed jobs are located in the /Shared Data folder.

Requirement Optional. If not specified for a deploy, deployed jobs will be created in the same location as the job object. If not specified for a redeploy, deployed jobs will be in the same folder where they already exist.

-log LOG PATH | LOG PATH AND FILENAME

specifies the path (or the path and filename) where the log file is to be written.

Requirement Optional.

-recursive

specifies whether the search for jobs should be recursive, starting at the folder specified with –objects. This argument has no value. If specified, the search is recursive through child folders. If not specified, the search is only in the specified folder.

Requirement Optional.

-since FROM ABSOLUTE DATE | FROM RELATIVE DATE

specifies that jobs are processed only if they have been modified after the specified date

Requirement Optional. See Specify Dates.

-useauthdomain TRUE | FALSE

when –true is specified, the authdomain is generated by the generated deployed code. When –false is specified, the user name and password are generated. When no value is specified, the authdomain is generated.

Note: The -recursive argument does not take a value. The other arguments must take an appropriate value.

Specify Connection Options

You must provide connection options to log on to the SAS Metadata Server when you use the command-line batch deployment tool.
These options, which are represented in syntax statements as connection options, are as follows:
Connection Options to Log On to the SAS Metadata Server
Option
Description
—host host-name
Identifies the host machine for the metadata server. This option is required if the -profile option is not set.
-port port
Specifies the port on which the metadata server runs. This option is required if the -profile option is not set.
-user user-ID
Specifies the user ID of the connecting user. This option is required if the -profile option is not set.
-password password
Specifies the password of the connecting user. This option is required if the -profile option is not set.
-profile profile
Specifies the name of the connection profile that is to be used to connect to the metadata server. The connection profile must exist on the computer where the command is executed. You can specify any connection profile that has been created for use with client applications such as SAS Management Console, SAS Data Integration Studio, and SAS OLAP Cube Studio. When you open one of these applications, the available connection profiles are displayed in the drop-down box in the Connect Profile dialog box.
This option can be provided in place of -host, -port, -user, and -password.

Specify Dates

When you use –since in a command, you can specify an absolute date (or an absolute date and time). Use one of the following formats:
  • MM/dd/yyyy
  • MM/dd/yyyy HH:mm:ss
  • yyyyMMdd
  • yyyyMMdd:HH:mm:ss
Note: If you do not specify a time, then the specified date begins at midnight (12:00:00 a.m.).
When you use –since in a command, you can specify a date relative to the current date. To specify a relative date, use one of the following values:
Today
specifies the current date, based on the date and time on the host machine for your machine
Yesterday
specifies the day just before the current date.
"Current day of last year"
specifies the same as the current date, except that the year is replaced with the previous year. For example, if the current date is October 12, 2013, then "Current day of last year" is October 12, 2012. February 29 is replaced with February 28.
"Current day of last month"
specifies the same as the current date, except that the month is replaced with the previous month. For example, if the current date is October 12, 2013, then "Current day of last month" is September 12, 2013. If the previous month has fewer days, the date is adjusted downward as necessary. For example, if the current date is October 31, 2013, then "Current day of last month" is September 30, 2013.
"Current day of last week"
specifies seven days previous to the current date. For example, if the current date is October 12, 2013, then "Current day of last week" is October 5, 2013.
"n days ago"
specifies n days previous to the current date. When specifying this option, replace n with an integer.
Note: Dates are assumed to begin at midnight (12:00:00 a.m.).

Run the Tool

Here is a sample command-line batch deployment tool command:
DeployJobs –profile “My Profile” –deploytype deploy –objects “/Shared Data/My Jobs/TransformJob” –sourcedir “c:\Source Data\Jobs” –deploymentdir “C:\SAS\Config\Lev1\SASApp\SASEnvironment\SASCode\Jobs” –metarepository Foundation –metaserverid A57CMFYM.AS000002 –servermachine “appserver machine name” –serverport 8591 –serverusername “user-id” –serverpassword “password” –batchserver “SASApp – SAS DATA Step Batch Server” –folder “Jobs/Deployed Jobs”
This command does the following:
  • Deploys the job TransformJob from the folder /Shared Data/My Jobs.
  • Deployed job code files are written to C:\SAS\Config\Lev1\SASApp\SASEnvironment\SASCode\Jobs.
  • Deployed job objects are created in the folder location Jobs/Deployed Jobs.
Note: If you need to run a command-line batch deployment job on the z/OS platform that contains quoted text, enclose the quoted section in the following escape characters:\”. This coding is illustrated in the following sample argument: -objects \"/Shared Data/DIS Testing/cmd/BVT_cmd\".
Last updated: January 16, 2018