Introduction
JS7 - Job Resources are a means to make variables available that can be shared by a number of jobs. Variables from Job Resources are exposed to:
- Shell jobs from OS environment variables
- JVM jobs from the JS7 - Job API
Job Resources are assigned a workflow to make variables available to all included jobs or they are assigned invidual jobs. When a Job Resource is updated then JS7 takes care that all Agents assigned to jobs that make use of the Job Resource will receive an updated copy of the Job Resource.
Typical use cases include:
- to make global settings such as paths etc. available from environment variables for shell jobs.
- to store encrypted secrets to Job Resources variables that can be decrypted by jobs. For details see JS7 - Encryption and Decryption.
- to store configuration files to Job Resource variables. The JS7 will make the configuration file available from a temporary file with releated Agents. Configuration files can be encrypted before being added to Job Resources, accordingly jobs can decrypt configuration files on-the-fly.
The JS7 offers to perform any operation on job resources, orders, workflows, jobs etc. by the JS7 - REST Web Service API, for details see the Technical Documentation of the REST Web Service API.
- The REST Web Service API can be accessed from Shell utilities such as
curl
. - Simplified access to the REST Web Service API is available from the JS7 - PowerShell Module.
The Job Resource Update cmdlet introduced in this article can be used to update variables in JS7 - Job Resources.
Job Resource Update Cmdlet
See PowerShell CLI 2.0 - Cmdlets - Set-JS7JobResource
- The cmdlet is available for Linux, MacOS® and Windows®.
- For installation of the JS7 PowerShell Module see PowerShell Command Line Interface 2.0 - Introduction.Encryption
Usage
PowerShell CLI 2.0 - Cmdlets - Invoke-JS7Encrypt
Examples
The following examples illustrate typical use cases.
Update Job Resource Variable
Set-JS7JobResource ` -Path /ProductDemo/Variables/pdBusinessDate ` -Key businessDate ` -Value (Get-Date (Get-Date).ToUniversalTime() -Format 'yyyy-MM-dd') ` -EnvVar 'BUSINESS_DATE' # updates the Job Resource variable "businessDate" from the current date UTC # receiving jobs can use the "BUSINESS_DATE" environment variable to receive the current value
Update Job Resource Variable from File
Set-JS7JobResource ` -Path /ProductDemo/Variables/pdConfigurationData ` -Key configurationData ` -File ./config.ini ` -EnvVar 'CONFIGURATION_DATA' # updates the Job Resource variable "configurationData" from the file specified # receiving jobs use the "CONFIGURATION_DATA" environment variable that specifies the path to a temporary file holding the configuration data
Update Job Resource Variable from Encrypted Value
Set-JS7JobResource ` -Path /ProductDemo/Variables/pdBusinessSecret ` -Key businessSecret ` -Value 'secret' ` -EnvVar 'BUSINESS_SECRET' ` -EncryptCertificatePath $env:JS7_AGENT_CONFIG_DIR/foobar.crt ` -JavaLib $env:JS7_AGENT_HOME/lib # updates the Job Resource variable "businessSecret" from some value # the value of the "businessSecret" variable will be encrypted using an Agent's certificate from the foobar.crt file # the value of the "businessSecret" variable holds the encrypted symmetric key, initialization vector and encrypted secret # the foobar.crt certificate file can be located anywhere in the file system # the JS7 encryption libraries specified with -JavaLib ship with Agents and are available for download if used outside of JS7 products
Update Job Resource Variable from Encrypted File
Set-JS7JobResource ` -Path /ProductDemo/Variables/pdConfigurationDataSecret ` -Key configurationDataSecret` ` -File ./config.ini ` -EnvVar 'CONFIGURATION_DATA_SECRET' ` -EncryptCertificatePath $env:JS7_AGENT_CONFIG_DIR/foobar.crt ` -JavaLib $env:JS7_AGENT_HOME/lib # updates the Job Resource variable "configurationDataSecret" from the file specified # the contents of the file will be encrypted using the target Agent's certificate from the foobar.crt file # an additional variable "configurationDateSecret_key" and environment variable "CONFIGURATION_DATA_SECRET_KEY" will be created that both hold the encrypted symmetric key and initialization vector # the foobar.crt certificate file can be located anywhere in the file system # the JS7 encryption libraries specified with -JavaLib ship with Agents and are available for download if used outside of JS7 products