Preferred one is with temporary file, as it gets success/error code also.
sh "echo foo > result";
def output=readFile('result').trim()
echo "output=$output";
More detailed
stage('Starting Tomcat')
{
steps{
node('master'){
sh 'docker run -d -p 9000:8080 tomcatserver > tomcat_server'
script
{
env.containerid = readFile('tomcat_server')
sh 'rm -f tomcatserver'
sh 'echo Containerd ID of Tomcat $containerid'
}
}
}
}
stage('Stop and Delete Tomcat')
{
steps{
node('master'){
echo "Stopping ${env.containerid}"
sh 'docker stop $containerid'
sh 'docker rm $containerid'
}
}
}
Reference
No comments:
Post a Comment