Page History
...
- Users can create a workflow with a single job that updates the
businessDate
variable. - The workflow is triggered by an order from JS7 - Schedules to switch the business date, for example, at midnight in the relevant time zone and for specific days.
Job for Unix using Shell
Download (.json upload): pduVariableBusinessDateSetShell.workflow.json
The job example for updating a business date uses the shell script explained with the JS7 - How to update a Job Resource using Unix Shell article.
Users have to download the shell script, make it executable and available in a directory that can be accessed by the Agent.
Download: JS7 - Download (Section: Utilities, Unix: js7.encryption.tar.gz
, Windows: js7.encryption.zip
)
The job performs the following operations:
- connect to the JOC Cockpit with the indicated user account.
- reading the Job Resource.
- updating the
businessDate
variable to the current date and specifying the desired date format. - storing the updated
businessDate
variable in the Job Resource. - deploying the updated Job Resource.
- disconnecting from JS7.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#!/bin/sh
$HOME/js7_set_job_resource.sh \
--url=http://joc-2-0-primary:7446 \
--controller-id=testsuite \
--user=root:root \
--job-resource=/ProductDemo/Variables/pdBusinessDate \
--key=businessDate \
--value=$(date +'%Y-%m-%d') |
Job for Unix using PowerShell
Download (.json upload): pduVariableBusinessDateSet.workflow.json
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#!/usr/bin/env pwsh # Adjust the path to your Job Resource $jobResourcePath = '/ProductDemo/Variables/pdBusinessDate' # Consider to use the appropriate URL that matches host and port of the JOC Cockpit instance $url = "http://joc-2-0-primary:4446" # Consider to store credentials with a PowerShell profile or with a credential store or to use certificate based authentication as an alternative to user/password $credentials = ( New-Object -typename System.Management.Automation.PSCredential -ArgumentList "root", ( "root" | ConvertTo-SecureString -AsPlainText -Force) ) Import-Module JS7 Connect-JS7 -Url $url -id $env:CONTROLLER_ID -Credentials $credentials $jobResource = Get-JS7InventoryItem -Path $jobResourcePath -Type JOBRESOURCE if ( $jobResource.arguments.BusinessDate ) { # update the business date $jobResource.arguments.BusinessDate = (Get-Date -Format "yyyy-MM-dd") } else { # add a business date variable to the Job Resource $jobResource.arguments | Add-Member -Membertype NoteProperty -Name BusinessDate -Value (Get-Date -Format "yyyy-MM-dd") } # Update and deploy the Job Resource Set-JS7InventoryItem -Path $jobResourcePath -Type JOBRESOURCE -Object $jobResource Publish-JS7DeployableItem -Path $jobResourcePath -Type JOBRESOURCE -ControllerID $env:CONTROLLER_ID Disconnect-JS7 |
Job for Windows using PowerShell
Download (.json upload): pdwVariableBusinessDateSet.workflow.json
...
- Consider use of the following shebang in the first line of the job script:
@@setlocal enabledelayedexpansion & @@findstr/v "^@@f^@@[fs].*&" "%~f0" | pwshpowershell.exe -&goto:eofNonInteractive -Command - & exit !errorlevel!/b&
- The PowerShell executable
pwsh.exe
is available starting from PowerShell 6.0. PowerShell releases 5.x use the executablepowershell.exe
that can be used accordingly with the shebang. - For details about the PowerShell shebang see the JS7 - How to run PowerShell scripts from jobs article.
...