Skip to content

Instantly share code, notes, and snippets.

@Rahulsharma0810
Created July 2, 2020 21:30
Show Gist options
  • Save Rahulsharma0810/1f6f4168d13b9fdd1c690e3705b4c88d to your computer and use it in GitHub Desktop.
Save Rahulsharma0810/1f6f4168d13b9fdd1c690e3705b4c88d to your computer and use it in GitHub Desktop.
Jenkins stage to get grep text on http endpoint
import groovy.io.FileType
/* groovylint-disable-next-line CompileStatic */
pipeline {
agent {
label ''
}
stages {
stage('1') {
steps {
timeout(time: 60, unit: 'MINUTES') {
script {
waitUntil {
sleep(60)
def VM_STATUS = sh script: """curl -s -X GET http://192.168.0.13/json | jq -r '.status'""", returnStdout: true
if (VM_STATUS.trim() == 'SUCCESSFUL' ) {
echo "Returned True, Got ${VM_STATUS}"
return true
} else {
echo "Retuned False,Got ${VM_STATUS}"
return false
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment