• Home
  • Jenkins
  • How do I get return value from sh (commandline)

How do I get return value from sh (commandline)

linkaiyi
Follow

Get return value of commandline

Following code get the return value

// 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}"

Following code get the return status

// Test commit message for flags
BUILD_FULL = sh (
    script: "git log -1 --pretty=%B | grep '\\[jenkins-full]'",
    returnStatus: true
) == 0
echo "Build full flag: ${BUILD_FULL}"
Object has 0 attachments

Was this article helpful?

This article is viewed 59 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support