Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Download Example for Windows (.json upload): pdwVariablesPassingWindows.workflow.json

First Job:

...

Pass Return Variables

Shell jobs can pass results to subsequent jobs:

...

Code Block
languagejs
titleExample of a Unix Shell job passing variables
linenumberstrue
collapsetrue
#!/usr/bin/node
 
const fs = require('fs');
 
// fetch the env.* variables
var name = (process.env.name);
var num = parseInt(process.env.num);
 
// print value of variable   
console.log(name);
console.log( num);

//Modify modify the values
var num1 = num + num;
console.log( num1);

var name1 = name + " This is JS7 ";
console.log( name1);

// pass results from a key/value pairpairs that isare appended to a temporary file provided by JS7

fs.appendFile(process.env.JS7_RETURN_VALUES, ,'num1=' + num1 + '\n', (err) => {});
fs.appendFile(process.env.JS7_RETURN_VALUES, ,'name1=' + name1 + '\n', (err) => {});
Code Block
languagejs
titleExample of a Windows Shell job passing variables
linenumberstrue
collapsetrue
@@findstr/v "^@@f.*&" "%~f0"|node.exe -&goto:eof

const fs = require('fs');
 
// fetch the env.* variables
var name = (process.env.name);
var num = parseInt(process.env.num);
 
// print value of variable   
console.log(name);
console.log( num);

//Modify modify the values
var num1 = num + num;
console.log( num1);

var name1 = name + " This is JS7 ";
console.log( name1);

// pass results from a key/value pairpairs that isare appended to a temporary file provided by JS7

fs.appendFile(process.env.JS7_RETURN_VALUES, ,'num1=' + num1 + '\n', (err) => {});
fs.appendFile(process.env.JS7_RETURN_VALUES, ,'name1=' + name1 + '\n', (err) => {});

Second Job: Read Variables

...

  • The JOC Cockpit GUI allows the mapping to be added per job from the right lower corner with the Environment Variables sub-tab.
  • The mapping includes free choice of the name of an environment variable which is used in the job script and to assign an existing order variable.
  • The spelling of variable names is case-sensitive.

Image Modified


The job script implementation looks like this:

Code Block
languagejs
titleExample of a Unix Shell job reading variables
linenumberstrue
collapsetrue
#!/usr/bin/node

var name1 = (process.env.name1);
var num1 = parseInt(process.env.num1);

// print value of variable   
console.log(name1);
console.log( num1);
Code Block
languagejs
titleExample of a Windows Shell job reading variables
linenumberstrue
collapsetrue
@@findstr/v "^@@f.*&" "%~f0"|node.exe -&goto:eof

var name1 = (process.env.name1);
var num1 = parseInt(process.env.num1);

// print value of variable   
console.log(name1);
console.log( num1);