Created
August 2, 2022 19:53
-
-
Save marcosanchotene/9ee28d3f3ae29d711a6134c8385640c2 to your computer and use it in GitHub Desktop.
Extract status code and response from curl request on Jenkins with Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
stage('Get response and status code') { | |
curlCommand = "curl -s -w '%{response_code}' www.example.com" | |
response = sh(script: curlCommand, returnStdout: true).trim() | |
responseCode = response.tokenize('\n').last() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment