Menu

JS7 - pass a variables calculated from job1 to job2

Help
Chico
2026-01-07
2026-01-08
  • Chico

    Chico - 2026-01-07

    Hi

    Is there a way in JS7 to pass a variables calculated from job1 to job2 ?

    for exemple:
    job1 : i have a small process to calculate a value and assign it to var1
    job2 : use var1 to get the result for another process.

    How can i archive that ?

    i was looking for ressource pool, but it seems it is more use for contant var you can't change for all the jobs.

     
  • Andreas

    Andreas - 2026-01-08

    Hi Chico,

    the JS7 - How to pass variables to subsequent jobs article explains how to achieve this.

     
  • Chico

    Chico - 2026-01-08

    tryed but still got errors.

    for info :
    on my job server, the agent is installed as js7 user.
    js7 have sudo right to su to other user without asking password.

    i have a chain of 2 job
    job 1 :

    #!/bin/bash
    sudo su - dsi << EOF
     whoami
     date_trt=$(date -d "last monday" +"%d-%m-%Y")
     echo "DATE_TRT=${date_trt}" >> ${JS7_RETURN_VALUES}
    EOF
    

    job2 : + it has an assigned evironnment variable DATE_TRT = $date_trt

    #!/bin/bash
    sudo su - dsi << EOF
     whoami
     echo "Date de traitement : ${DATE_TRT}"
    EOF
    

    for me it's the same as to doc says.

    But, runs failed at job 1 with this errors :

    2026-01-08 08:50:57.978+01:00 [MAIN]    [Start] Job=test1, label=test1, Agent(url=http://10.0.0.139:4445, id=s-batch, name=s-batch)
    2026-01-08 08:50:58.033+01:00 [STDOUT]  dsi
    2026-01-08 08:50:58.046+01:00 [STDERR]  -bash: line 3: /var/js7_agent/var_4445/work/tmp/returnValues-13834494208967025215.tmp: Permission denied
    2026-01-08 08:50:58.046+01:00 [MAIN]    [End] [Error] returnCode=1, errorState=failed, reason=failed, msg=-bash: line 3: /var/js7_agent/var_4445/work/tmp/returnValues-13834494208967025215.tmp: Permission denied
    2026-01-08 08:50:58.022+01:00 [ERROR] [OrderProcessed] id=#2026-01-08#T85865788328-root, Job=test1, label=test1, pos=0, Agent(time=2026-01-08 08:50:58.046+01:00), Error (status=failed, msg=-bash: line 3: /var/js7_agent/var_4445/work/tmp/returnValues-13834494208967025215.tmp: Permission denied), returnCode=1
    2026-01-08 08:50:58.052+01:00 [ERROR] [OrderFailed] id=#2026-01-08#T85865788328-root, pos=0, Error (status=failed, msg=[Job=test1, pos=0]-bash: line 3: /var/js7_agent/var_4445/work/tmp/returnValues-13834494208967025215.tmp: Permission denied), returnCode=1
    

    because the file tries to be written as dsi user instead of agent's user ?
    if then, how can i put a conf in the agent to set this tmp access right to 777 by default ?

     
  • Andreas

    Andreas - 2026-01-08

    Hi Chico,

    you have a spelling error in your confirugration.

    • job1
      • echo "DATE_TRT=${date_trt}" >> ${JS7_RETURN_VALUES}
      • This means you create the dynamic workflow variable DATE_TRT in uppercase letters.
    • job2
      • it has an assigned evironnment variable DATE_TRT = $date_trt

      • This means you assign the lowercase variable name date_trt. Make the variable name uppercase as used in job1 to make this work.
     
  • Chico

    Chico - 2026-01-08

    alright i thought echo "DATE_TRT=${date_trt}" >> ${JS7_RETURN_VALUES} meant i create en JS7 env var named DATE_TRT with the value incide the $date_trt from the script.

    checked this, but still got the error of temporary file i can't find how to solve

    running the jobs without sudo su - worked fine, the 2 job get the value from job 1
    but, i have to run the job in specific user env, so i have to keep the sudo su - dsi << EOF before executing, and that cause the temp file error.
    only got this error to pass var from job to another, on standalone jobs (without env vars) i don't have this error.

     

Log in to post a comment.

MongoDB Logo MongoDB