You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Introduction

  • Shell Jobs can be used for a number of scripting languages such as Bash, Perl, PowerShell etc.
    • Users frequently re-use code snippets across a number of jobs, for example re-usable functions that are called in a number of jobs scripts.
    • This applies to Shell Jobs using Bash etc. and it applies to use of any scripting languages.
  • Code snippets can be managed by use of Script Includes that are available as inventory items in the Configuration view of JOC Cockpit.
  • FEATURE AVAILABILITY STARTING FROM RELEASE 2.2.0
  • JOC-1170 - Getting issue details... STATUS

Managing Script Includes

Script Includes are managed from the Configuration view, for example to define functions that can be used across job scripts in a number of workflows:


Script Includes can similarly be used to define environment variables that are used in a number of shell scripts:


Hint:

  • Use of JS7 - Job Resources is preferable if the only purpose of the Script Include is to publish environment variables to shell scripts. 

Applying Script Includes

Script Includes can be applied to any Shell Jobs. Consider the example of a workflow that includes a Shell Job like this:


The job script in the above workflow looks like this:


Script Includes can be added to a job script in a number of ways:

  • Users can type ##!include at the begin of a line in the job script followed by the name of the Script Include.
  • When hitting Ctrl+Space directly after typing ##!include then a popup window offers the list of available Script Includes for selection.
  • The first line of the script editor popup window offers the icon. Clicking this icon displays the list of folders from which to choose a Script Include that is added to the cursor position:



Syntax

Script Includes can be added to a job script by use of the following syntax:

Syntax to embed Script Includes
(##|::|//)!include script-include-name [--replace="search literal","replacement literal" [--replace=...]]

Explanation:

  • The first two characters in a line of the job script are: ## or :: or //
  • followed by: !include
  • followed by the name of the Script Include
  • optionally followed by repeated occurrences of: --replace="...", "..."
    • the --replace option accepts
      • as its first argument a literal string to be searched for in the Script Include,
      • as its second argument the literal replacement for the search literal.
    • This option can occur any number of times.
  • Any number of Script Includes can be embedded to a job script.

Examples

Find a number of examples how to apply Script Includes:

Examples how to embed Script Includes
##!include pdScriptBashFunctions

##!include pdScriptBashEnvironmentVariables --replace="/tmp/js7","/home/js7" --replace="/var/myapp","/home/js7/myapp"


Handling of Script Includes

Deployment

  • Script Includes are embedded at the point in time of deployment of a workflow.
  • Script Includes have to be released in order to be considered for deployment with a workflow.

Change Management

  • If the contents of a Script Include is modified after deployment of a workflow then this change does not affect the deployed workflow.
  • If a Script Include does not exist any longer at the point in time of deployment of a workflow then an error is raised.
  • If the name of a Script Include is modified then this is reflected with jobs in any workflows that make use of the Script Include. For any affected workflows a draft is created that includes the modified reference to the Script Include.


  • No labels