def main(args): """ Main function for the pipeline. Executes all sub-tasks :param args: Parsed command line arguments """ logger = initPipelineLogger("manifest", logLevel=args.logLevel) buildWorkspace = os.environ.get("BUILD_WORKSPACE", None) if not buildWorkspace: baseDir = jenkins.getWorkspace() buildId = jenkins.getBuildNumber() buildWorkspace = mkdtemp(prefix=buildId, dir=baseDir) manifest = vars(args) # Update buildWorkspace in manifest section for pipelineJson manifest.update({"buildWorkspace": buildWorkspace}) manifestEnv = {"manifest": manifest} with open("%s/%s_pipeline.json" % (buildWorkspace, args.pipeline), 'w') as fp: fp.write(json.dumps(manifestEnv, ensure_ascii=False)) logger.debug(json.dumps(manifestEnv)) pipelineJsonPath = "%s/%s_pipeline.json" % (buildWorkspace, args.pipeline) logger.info("Pipeline JSON path: %s", pipelineJsonPath) return pipelineJsonPath
def prepareResultsDir(): """ Make sure that a results directory exists in the right place. Return the path of the results directory. :returns: The full path of the results directory :rtype: String """ resultsDir = os.path.join(getWorkspace(), "results") if not os.path.exists(resultsDir): os.makedirs(resultsDir) return resultsDir