Fixed debugging output
Change-Id: I0a4e7c73561c95345cb30031aab7b441aea42f00
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 1c958b5..daf9f38 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -145,7 +145,7 @@
*/
def debugMsg(msg, color = true){
// if debug property exists on env, debug is enabled
- if(env.getEnvironment().containsKey('DEBUG')){
+ if(env.getEnvironment().containsKey('DEBUG') && env['DEBUG'] == "true"){
printMsg("[DEBUG] ${msg}", "red")
}
}
diff --git a/src/com/mirantis/mk/Http.groovy b/src/com/mirantis/mk/Http.groovy
index 8881fff..c8cc156 100644
--- a/src/com/mirantis/mk/Http.groovy
+++ b/src/com/mirantis/mk/Http.groovy
@@ -15,7 +15,6 @@
*/
@NonCPS
def sendHttpRequest(url, method = 'GET', data = null, headers = [:]) {
- //def common = new com.mirantis.mk.Common()
def connection = new URL(url).openConnection()
if (method != 'GET') {
connection.setRequestMethod(method)
@@ -39,7 +38,9 @@
} else {
dataStr = new groovy.json.JsonBuilder(data).toString()
}
- //common.debugMsg("[HTTP] Request URL: ${url}, method: ${method}, headers: ${headers}, content: ${dataStr}")
+ if(env.getEnvironment().containsKey('DEBUG') && env['DEBUG'] == "true"){
+ println("[HTTP] Request URL: ${url}, method: ${method}, headers: ${headers}, content: ${dataStr}")
+ }
def output = new OutputStreamWriter(connection.outputStream)
output.write(dataStr)
output.close()
@@ -52,10 +53,14 @@
} catch (groovy.json.JsonException e) {
response_content = response
}
- //common.debugMsg("[HTTP] Response: code ${connection.responseCode}")
+ if(env.getEnvironment().containsKey('DEBUG') && env['DEBUG'] == "true"){
+ println("[HTTP] Response: code ${connection.responseCode}")
+ }
return response_content
} else {
- //common.debugMsg("[HTTP] Response: code ${connection.responseCode}")
+ if(env.getEnvironment().containsKey('DEBUG') && env['DEBUG'] == "true"){
+ println("[HTTP] Response: code ${connection.responseCode}")
+ }
throw new Exception(connection.responseCode + ": " + connection.inputStream.text)
}
}