the artifacts (build.tar.gz) are currently being made irrespective of whether the build is finished properly. This should not be... it the artifact should be created by the job in jenkins, not the script, as is currently happening.