I have a Jenkinsfile that calls a shell script:
        stage('Terraform Plan') {
            steps {
                    sh 'chmod +x ./jenkins_plan.sh'
                    sh 'bash jenkins_plan.sh'
            }
        }
The shell script (jenkins_plan.sh) has the following commands in it:
        cd "$dir"
        terraform init
        terraform validate 
        terraform plan -lock=false -input=false -out tfplan
        terraform show -no-color tfplan > tfplan.txt
I would like to send the output (tfplan.txt) from the shell script to the Jenkinsfile so I can do something similar to:
        stage('Terraform Plan') {
            steps {
                    sh 'chmod +x ./jenkins_plan.sh'
                    sh 'bash jenkins_plan.sh'
               script{
                    env.PLAN_OUTPUT = readFile('tfplan.txt')
                }
            }
        }
Any help would be greatly appreciated.