def main(jsonArgs): """ Main function. :param jsonArgs: dict of pipeline-json and logLevel, defaults to empty dict to make the script work independently and via driver scripts. e.g. {"pipelineJson" : <PIPELINE_JSON_PATH>, "logLevel" : <LOG_LEVEL>} :param jsonArgs: dict of pipeline-json and logLevel e.g. {"pipelineJson" : <PIPELINE_JSON_PATH>, "logLevel" : <LOG_LEVEL>} """ try: pipelineConfig = addAndParseArgs(jsonArgs) htm-itUser = getGithubUserName(pipelineConfig["htm-itRemote"]) amiName = (htm-itUser + "-" + pipelineConfig["htm-itBranch"]) env = prepareEnv(pipelineConfig["buildWorkspace"], None, os.environ) preBuildSetup(env, pipelineConfig) builder.buildHTM-IT(env, pipelineConfig, g_logger) g_logger.debug("HTM-IT built successfully!") deployTrack = getDeployTrack(pipelineConfig["htm-itRemote"], pipelineConfig["htm-itBranch"]) pipelineConfig["pipelineParams"]["build"] = { "htm-itSha": pipelineConfig["htm-itSha"], "htm-itHome": env["HTM-IT_HOME"], "deployTrack": deployTrack, "htm-itDeployTrack": htm-itUser, "amiName": amiName } g_logger.debug(pipelineConfig["pipelineParams"]) if pipelineConfig["pipelineJson"]: with open(pipelineConfig["pipelineJson"], 'w') as jsonFile: jsonFile.write(json.dumps(pipelineConfig["pipelineParams"], ensure_ascii=False)) except Exception: g_logger.exception("Unknown error occurred in build phase") raise
:returns: A `string` representing the deployment track e.g. 1) htm-itRemote: [email protected]:<user-name>/numenta-apps.git deployTrack: <user-name>-numenta 2) htm-itRemote: [email protected]:Numenta/numenta-apps.git deployTrack: htm-itsolutions :rtype: string """ if checkIfSaneProductionParams(htm-itRemote, htm-itBranch): return "htm-itsolutions" else: return getGithubUserName(htm-itRemote) + "-numenta" def preBuildSetup(env, pipelineConfig): """ Clone the HTM-IT repo if needed and get it set to the right remote, branch, and SHA. :param env: The environment variable which is set before building :param pipelineConfig: dict of the pipeline config values, e.g.: { "buildWorkspace": "/path/to/build/in", "htm-itRemote": "[email protected]:Numenta/numenta-apps.git", "htm-itBranch": "master", "htm-itSha": "HEAD", "pipelineParams": "{dict of parameters}",