Source error on setting environment variables

I have two sh files in my concourse pipeline - tasks where I am trying to export the variable from one sh file to another sh file.I have followed the below steps.when I am sourcing from my mac terminal I am able to use the variable setup in file1.sh to file2.sh.But the pipeline in concourse has two tasks where first task runs the file1.sh and second task runs file2.sh.How can I source the script file in concourse pipelines.

file1.sh
#!/usr/bin/env bash
export test=${test}

file2.sh
echo ${test}

If I understand you correctly you have something like (pseudo code):

plan:
- get: resource1
- get: resource2
- task: task1
  file: resource1/file1.sh
- task: task2
  file: resource2/file2.sh

but file2.sh actually needs to source file1.sh. If resource1 and resource2 are the same (i.e. both scripts are in the same repo) or both resources are inputs to task2 then you should be able to just modify file2.sh to be something like:

source path/to/file1.sh
echo ${test}

Does this help?

yes this helped me.thanks very much

This is helpful Thanks for sharing
VMware