title: Jenkins pass a shell script variable to a down stream job
body: <p>I'm new to Jenkins.</p>
  <p>I have a job with an &quot;Execute Shell&quot; Build trigger, and in that shell script i initiate some variables with values i take from some source.</p>
  <p>I need to pass these values to a downstream job.</p>
  <p>The values i want to pass are $IMG_NAME and $IMG_PATH from this shell script:</p>
  <pre><code> #!/bin/bash -x
  
  whoami
  
  echo &quot;BASE_PATH: $BASE_PATH&quot;
  
  declare -A BRANCHES
  
  for i in $(echo $BRANCHES_LIST | tr ',' '\n'); do BRANCHES[$i]= ; done
  
  echo 'user' | sudo -S umount -rf /mnt/tlv-s-comp-prod/drops/
  
  echo 'user' | sudo -S mount.nfs -o nolock,nfsvers=3 tlv-s-comp-prod:/export/drops /mnt/tlv-s-comp-prod/drops
  
  ls /mnt/tlv-s-comp-prod/drops/
  
  echo &quot;cleanup workspace&quot;
  rm ${WORKSPACE}/*.txt &amp;&gt; /dev/null
  
  i=&quot;0&quot;
  while [ $i -lt 6 ]
  do
  
    if [[ ${BASE_PATH} == *&quot;Baseline&quot;* ]]; then
        unset BRANCHES[@]
        declare -A BRANCHES
        BRANCHES[Baseline]=
    fi
    for BRANCH in &quot;${!BRANCHES[@]}&quot;; do
        echo &quot;BRANCH: $BRANCH&quot;
        if [ $BRANCH == &quot;Baseline&quot; ]; then BRANCH=; fi
        img_dir=$(ls -td -- ${BASE_PATH}/${BRANCH}/*/ | head -n 1)
        echo &quot;img_dir: $img_dir&quot;
        IMG_PATH=$(ls $img_dir*.rpm)
        echo &quot;IMG_PATH: $IMG_PATH&quot;
        cd $img_dir
        IMG_NAME=$(ls *.rpm) &gt; env.properties
        if [ ! -z &quot;$IMG_NAME&quot; ]; then
            if [ $(( $(date +%s) - $(stat -c %Z $IMG_PATH) )) -lt 10000800 ]; then
              echo &quot;IMG_NAME: ${IMG_NAME}&quot; 
              #BRANCHES[$BRANCH]=$IMG_PATH
              #echo &quot;REG_OSA_SOFTSYNC_BUILD_IMG_FULL_PATH=${BRANCHES[$BRANCH]}&quot; &gt;&gt; ${WORKSPACE}/$BRANCH.txt
              echo &quot;BRANCH_NAME=$BRANCH&quot; &gt;&gt; ${WORKSPACE}/${BRANCH}_branch.txt
              echo &quot;REG_OSA_SOFTSYNC_BUILD_NAME=$BRANCH-$IMG_NAME&quot; &gt;&gt; ${WORKSPACE}/${BRANCH}_branch.txt
             
            else
                echo &quot;$IMG_NAME is out dated&quot;
            fi  
        else
            echo &quot;IMG_NAME is empty&quot;
        fi
              BRANCH_NAME=&quot;&quot;
    done
    
    $TEMP=$BRANCH_NAME
    echo &quot;TEMP: $TEMP&quot;
    
  
    if [ $(ls ${WORKSPACE}/*_branch.txt | wc -l) == $(echo ${#BRANCHES[@]}) ]; then break; fi
    
    #for i in $(ls *_branch.txt); do i=$(echo $i | awk -F '_branch.txt' '{print $1}'); if [ $(echo ${!BRANCHES[@]} | grep $i | wc -l) == 0 ]; then state=1 break; fi done
    
    
    i=$[$i+1]
    
    sleep 1800
    
  done
  </code></pre>
  <p><a href="https://i.stack.imgur.com/kRnh3.png" rel="nofollow noreferrer">This is the &quot;Trigger parameterized build on other projects&quot; configuration:</a></p>