How do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?

The latest version of the pipeline sh step allows you to do the following; // Git committer email GIT_COMMIT_EMAIL = sh ( script: ‘git –no-pager show -s –format=\’%ae\”, returnStdout: true ).trim() echo “Git committer email: ${GIT_COMMIT_EMAIL}” Another feature is the returnStatus option. // Test commit message for flags BUILD_FULL = sh ( script: “git log … Read more

Jenkins CI Pipeline Scripts not permitted to use method groovy.lang.GroovyObject

Quickfix Solution: I had similar issue and I resolved it doing the following Navigate to jenkins > Manage jenkins > In-process Script Approval There was a pending command, which I had to approve. Alternative 1: Disable sandbox As this article explains in depth, groovy scripts are run in sandbox mode by default. This means that … Read more