Right now I am a newbie for Shell, Jenkins, Groovy pipeline. My requirement is I am reading file text into a variable under shell script and I need to pass this variable value out of shell script and to use in Groovy script.
Here is my code:
stages
{
stage('example')
{
steps
{
script
{
sh'''
#!/bin/bash
set +x
readVal=$(<$WORKSPACE/test.json)
echo "$readVal" //this is priting my entire json successfully
echo 'closing shell script'
'''
println WORKSPACE /// this is printing my workspace value successfully
println readVal // not working
println env.readVal // not working
println $readVal // not working
}
}
}
}
How to get readVal's value out of shell to access?