Skip to content

Instantly share code, notes, and snippets.

@marcosanchotene
Created August 2, 2022 19:53
Show Gist options
  • Save marcosanchotene/9ee28d3f3ae29d711a6134c8385640c2 to your computer and use it in GitHub Desktop.
Save marcosanchotene/9ee28d3f3ae29d711a6134c8385640c2 to your computer and use it in GitHub Desktop.
Extract status code and response from curl request on Jenkins with Groovy
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