I’m running a python script from Jenkins pipeline(groovy):
email = sh(returnStdout: true, script: "python3.9 -u scripts/validate_email.py")
The script validate_email.py
returns a String value that I am capturing in email
variable.
That works fine but since I use returnStdout: true
the output from the script is not printed out to the Jenkins log, which is expected based on the definition.
If I remove returnStdout: true
the output from the script is printed to the Jenkins log but now I cannot capture a return value.
Is there a way to capture the return value from the script and still print out the output to Jenkins logs?
I tried using print("something")
and
import logging as log
log.info("something")
as different ways to print but neither helped.