diff options
-rw-r--r-- | mason/tests/artifact_upload.py | 23 | ||||
-rw-r--r-- | mason/tests/build.py | 9 | ||||
-rw-r--r-- | mason/tests/build_test.py | 9 |
3 files changed, 31 insertions, 10 deletions
diff --git a/mason/tests/artifact_upload.py b/mason/tests/artifact_upload.py index aa6c56f..62e74e1 100644 --- a/mason/tests/artifact_upload.py +++ b/mason/tests/artifact_upload.py @@ -76,14 +76,17 @@ class Runner(mason.runners.JobRunner): self.log.info('Step 1: Creating a workspace') self._create_workspace() - if self.config['upload-build-artifacts']: - self.log.info('Step 2: Publish the build artifacts') - self._publish_build_artifacts() - - if self.config['upload-release-artifacts']: - self.log.info('Step %d: Publish the release artifacts' % - (self.current_step + 1)) - self._publish_release_artifacts() + try: + if self.config['upload-build-artifacts']: + self.log.info('Step 2: Publish the build artifacts') + self._publish_build_artifacts() + + if self.config['upload-release-artifacts']: + self.log.info('Step %d: Publish the release artifacts' % + (self.current_step + 1)) + self._publish_release_artifacts() + except: + self._remove_workspace() self.log.info('Step %d: Clean up' % (self.current_step + 1)) self._clean_up() @@ -94,6 +97,7 @@ class Runner(mason.runners.JobRunner): @mason.util.job_step def _create_workspace(self): + os.chdir('/root') self.commit = self.job_arguments['ZUUL_COMMIT'] self.project = self.job_arguments['ZUUL_PROJECT'] self.ref = self.job_arguments['ZUUL_REF'] @@ -127,4 +131,7 @@ class Runner(mason.runners.JobRunner): @mason.util.job_step def _clean_up(self): + self._remove_workspace() + + def _remove_workspace(self): cliapp.runcmd(['rm', '-rf', self.workspace]) diff --git a/mason/tests/build.py b/mason/tests/build.py index de5a178..78d2334 100644 --- a/mason/tests/build.py +++ b/mason/tests/build.py @@ -68,7 +68,10 @@ class Runner(mason.runners.JobRunner): self._prepare_build_log_dir() self.log.info('Step 3: Building the systems') - self._build_systems() + try: + self._build_systems() + except: + self._remove_workspace() self.log.info('Step 4: Clean up') self._clean_up() @@ -100,6 +103,7 @@ class Runner(mason.runners.JobRunner): @mason.util.job_step def _create_workspace(self): + os.chdir('/root') self.commit = self.job_arguments['ZUUL_COMMIT'] self.project = self.job_arguments['ZUUL_PROJECT'] self.ref = self.job_arguments['ZUUL_REF'] @@ -153,4 +157,7 @@ class Runner(mason.runners.JobRunner): os.chdir('/root') #TODO: don't do this in production self._do_git_config(name='Adam Coldrick', email='adam.coldrick@codethink.co.uk') + self._remove_workspace() + + def _remove_workspace(self): cliapp.runcmd(['rm', '-rf', self.workspace]) diff --git a/mason/tests/build_test.py b/mason/tests/build_test.py index 09ce7db..ac007bd 100644 --- a/mason/tests/build_test.py +++ b/mason/tests/build_test.py @@ -42,7 +42,10 @@ class Runner(mason.runners.JobRunner): self._prepare_log_dir() self.log.info('Step 3: Deploy and test the systems') - self._deploy_and_test_systems() + try: + self._deploy_and_test_systems() + except: + self._remove_workspace() self.log.info('Step 4: Clean up') self._clean_up() @@ -115,6 +118,7 @@ class Runner(mason.runners.JobRunner): @mason.util.job_step def _create_workspace(self): + os.chdir('/root') self.commit = self.job_arguments['ZUUL_COMMIT'] self.project = self.job_arguments['ZUUL_PROJECT'] self.ref = self.job_arguments['ZUUL_REF'] @@ -203,4 +207,7 @@ class Runner(mason.runners.JobRunner): @mason.util.job_step def _clean_up(self): + self._remove_workspace() + + def _remove_workspace(self): cliapp.runcmd(['rm', '-rf', self.workspace]) |