diff --git a/cvp-shaker.groovy b/cvp-shaker.groovy
index f845bc8..08f9315 100644
--- a/cvp-shaker.groovy
+++ b/cvp-shaker.groovy
@@ -1,15 +1,15 @@
-/**
+/*
  *
  * Launch CVP Shaker network tests
  *
  * Expected parameters:
-
+ *
  *   SALT_MASTER_URL             URL of Salt master
  *   SALT_MASTER_CREDENTIALS     Credentials that are used in this Jenkins for accessing Salt master (usually "salt")
  *   IMAGE                       Docker image link to use for running container with Shaker.
  *   SHAKER_PARAMS               Yaml context which contains parameters for running Shaker
  *
- */
+*/
 
 /*
 SHAKER_PARAMS yaml example:
@@ -74,97 +74,94 @@
 def SHAKER_PARAMS = readYaml(text: env.getProperty('SHAKER_PARAMS')) ?: [:]
 def artifacts_dir = 'validation_artifacts'
 def configRun = [:]
+def workdir = '/opt/shaker/'
+def container_artifacts = '/artifacts'
+def html_file = "${container_artifacts}/shaker-report.html"
+def cmd_shaker_args = "--debug --cleanup-on-error --report ${html_file}"
 
 node (SLAVE_NODE) {
-    try{
-        stage('Initialization') {
-            def workdir = '/opt/shaker/'
-            def container_artifacts = '/artifacts'
-            def html_file = "${container_artifacts}/shaker-report.html"
-            def log_file = "${container_artifacts}/shaker.log"
-            def cmd_shaker_args = "--debug --cleanup-on-error " +
-                "--log-file ${log_file} --report ${html_file}"
+    stage('Initialization') {
 
-            sh "mkdir -p ${artifacts_dir}"
-
-            // Get Openstack credentials
-            def saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+        // prepare artifacts directory
+        sh "rm -rf ${artifacts_dir} || true"
+        sh "mkdir -p ${artifacts_dir}"
+        // Get Openstack credentials
+        def saltMaster = salt.connection(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS)
+        try {
             keystone_creds = validate._get_keystone_creds_v3(saltMaster)
             if (!keystone_creds) {
                 keystone_creds = validate._get_keystone_creds_v2(saltMaster)
             }
-
-            // Get shaker env variables
-            def general_params = [
-                SHAKER_SERVER_ENDPOINT: (SHAKER_PARAMS.get('SHAKER_SERVER_ENDPOINT')),
-                SHAKER_SCENARIOS: (SHAKER_PARAMS.get('SHAKER_SCENARIOS')) ?: 'scenarios/essential',
-                SKIP_LIST: (SHAKER_PARAMS.get('SKIP_LIST')),
-                MATRIX: (SHAKER_PARAMS.get('MATRIX'))
-            ]
-            if (! general_params['SHAKER_SERVER_ENDPOINT']) {
-                throw new Exception("SHAKER_SERVER_ENDPOINT address was not set in the SHAKER_PARAMS")
-            }
-            def builder_vars = SHAKER_PARAMS.get("image_builder") ?: [
-                "SHAKER_FLAVOR_DISK=4",
-                "SHAKER_FLAVOR_RAM=512",
-                "SHAKER_FLAVOR_VCPUS=1"
-            ]
-            def shaker_vars = SHAKER_PARAMS.get("shaker") ?: []
-            def env_vars_list = general_params.collect{ "${it.key}=${it.value}" }
-            env_vars_list = env_vars_list + keystone_creds + builder_vars + shaker_vars
-
-            // Get shaker scenarios cmd
-            def scen_cmd = validate.bundle_up_scenarios(
-                workdir +
-                general_params['SHAKER_SCENARIOS'].replaceAll("^/+", ""),
-                general_params['SKIP_LIST']
-            )
-
-            // Override scenarios params:
-            if (general_params['MATRIX']) {
-                cmd_shaker_args += " --matrix '${general_params.MATRIX}'"
-            }
-
-            // Define docker commands
-            def commands = [
-                '001_build_image': "shaker-image-builder --debug",
-                '002_run_shaker': scen_cmd + "-print0" +
-                    "|paste -zsd ',' - " +
-                    "|xargs --null " +
-                    "shaker ${cmd_shaker_args} --scenario "
-            ]
-            def commands_list = commands.collectEntries{ [ (it.key) : { sh("${it.value}") } ] }
-
-            configRun = [
-                'image': IMAGE,
-                'baseRepoPreConfig': false,
-                'dockerMaxCpus': 2,
-                // suppress sudo resolve warnings
-                // which break image build
-                'dockerHostname': 'localhost',
-                'dockerExtraOpts': [
-                    "--network=host",
-                    "--privileged",
-                    "-v ${env.WORKSPACE}/${artifacts_dir}/:${container_artifacts}"
-                ],
-                'envOpts'         : env_vars_list,
-                'runCommands'     : commands_list
-            ]
+        } catch (Throwable e) {
+            error("This test requires Openstack keystone credentials to start (${e.toString()})")
         }
 
-        stage('Run Shaker tests') {
-            salt_testing.setupDockerAndTest(configRun)
+        // Get shaker env variables
+        def general_params = [
+            SHAKER_SERVER_ENDPOINT: (SHAKER_PARAMS.get('SHAKER_SERVER_ENDPOINT')),
+            SHAKER_SCENARIOS: (SHAKER_PARAMS.get('SHAKER_SCENARIOS')) ?: 'scenarios/essential',
+            SKIP_LIST: (SHAKER_PARAMS.get('SKIP_LIST')),
+            MATRIX: (SHAKER_PARAMS.get('MATRIX'))
+        ]
+        if (! general_params['SHAKER_SERVER_ENDPOINT']) {
+            throw new Exception("SHAKER_SERVER_ENDPOINT address was not set in the SHAKER_PARAMS")
+        }
+        def builder_vars = SHAKER_PARAMS.get("image_builder") ?: [
+            "SHAKER_FLAVOR_DISK=4",
+            "SHAKER_FLAVOR_RAM=512",
+            "SHAKER_FLAVOR_VCPUS=1"
+        ]
+        def shaker_vars = SHAKER_PARAMS.get("shaker") ?: []
+        def env_vars_list = general_params.collect{ "${it.key}=${it.value}" }
+        env_vars_list = env_vars_list + keystone_creds + builder_vars + shaker_vars
+
+        // Get shaker scenarios cmd
+        def scen_cmd = validate.bundle_up_scenarios(
+            workdir +
+            general_params['SHAKER_SCENARIOS'].replaceAll("^/+", ""),
+            general_params['SKIP_LIST']
+        )
+
+        // Override scenarios params:
+        if (general_params['MATRIX']) {
+            cmd_shaker_args += " --matrix '${general_params.MATRIX}'"
         }
 
-        stage('Collect results') {
-            archiveArtifacts artifacts: "${artifacts_dir}/*"
-        }
+        // Define docker commands
+        def commands = [
+            '001_build_image': "shaker-image-builder --debug",
+            '002_run_shaker': scen_cmd +
+                "|paste -sd ',' - " +
+                "|xargs shaker ${cmd_shaker_args} --scenario"
+        ]
+        def commands_list = commands.collectEntries{ [ (it.key) : { sh("${it.value}") } ] }
 
-    } catch (Throwable e) {
-        // If there was an error or exception thrown, the build failed
-        currentBuild.result = "FAILURE"
-        throw e
-    } finally {
-        sh "rm -rf ${artifacts_dir}"
+        configRun = [
+            'image': IMAGE,
+            'baseRepoPreConfig': false,
+            'dockerMaxCpus': 2,
+            // suppress sudo resolve warnings
+            // which break image build
+            'dockerHostname': 'localhost',
+            'dockerExtraOpts': [
+                "--network=host",
+                "--privileged",
+                "-v ${env.WORKSPACE}/${artifacts_dir}/:${container_artifacts}"
+            ],
+            'envOpts'         : env_vars_list,
+            'runCommands'     : commands_list
+        ]
     }
+
+    stage('Run Shaker tests') {
+        if (! salt_testing.setupDockerAndTest(configRun)) {
+            common.warningMsg('Docker contrainer failed to run Shaker')
+            currentBuild.result = 'FAILURE'
+        }
+    }
+
+    stage('Collect results') {
+        archiveArtifacts artifacts: "${artifacts_dir}/*"
+    }
+
 }
