示例#1
0
def environment_setup():
    # Grab all of the environment variables
    env = os.environ
    jira_base_url = StepUtility.getEnvironmentVariable('JIRA_BASE_URL', env)
    jira_username = StepUtility.getEnvironmentVariable('JIRA_USERNAME', env)
    jira_api_key = StepUtility.getEnvironmentVariable('JIRA_API_KEY', env)
    action = StepUtility.getEnvironmentVariable('ACTION', env)

    # Logic here to use the regex to grab the jira issue key and assign it to issue
    jira_issue_source_field = StepUtility.getEnvironmentVariable('JIRA_ISSUE_SOURCE_FIELD', env)
    jira_issue_source_field_regex = StepUtility.getEnvironmentVariable('JIRA_ISSUE_SOURCE_FIELD_REGEX', env)
    ## TODO - Brandon - need to do regex work here
    issue = jira_issue_source_field

    # Issue fields below
    # Retrieve the project environment variable and add the project to a dict representation
    issue_project_env = StepUtility.getEnvironmentVariable('ISSUE_PROJECT', env)
    issue_project = None
    if issue_project_env:
        issue_project = "{'key': '" + issue_project_env + "'}"

    issue_summary = StepUtility.getEnvironmentVariable('ISSUE_SUMMARY', env)
    issue_description = StepUtility.getEnvironmentVariable('ISSUE_DESCRIPTION', env)

    # Retrieve the type environment variable and add the type to a dict representation
    issue_type_env = StepUtility.getEnvironmentVariable('ISSUE_TYPE', env)
    issue_type = None
    if issue_type_env:
        issue_type = "{'name': '" + issue_type_env + "'}"

    # Retrieve the components, split the list, and create an array of dicts with each component
    issue_components_env = StepUtility.getEnvironmentVariable('ISSUE_COMPONENTS', env)
    issue_components = None
    if issue_components_env:
        issue_components = []
        split_components = issue_components_env.split(",")
        for component in split_components:
            component_string = "{'name': '" + component + "'}"
            issue_components.append(ast.literal_eval(component_string))

    # Retrieve customfields
    issue_customfields = StepUtility.getEnvironmentVariable('ISSUE_CUSTOMFIELDS', env)

    # Retrieve the comment information
    existing_comment_id = StepUtility.getEnvironmentVariable('JIRA_COMMENT_ID', env)
    comment_body = StepUtility.getEnvironmentVariable('COMMENT_BODY', env)

    # Desired Jira status information
    status = StepUtility.getEnvironmentVariable('DESIRED_ISSUE_STATUS', env)
    jql_query = StepUtility.getEnvironmentVariable('JQL_QUERY', env)
    jql_query_max_results = 50
    jql_query_max_results_env = StepUtility.getEnvironmentVariable('JQL_QUERY_MAX_RESULTS', env)
    if jql_query_max_results_env:
        jql_query_max_results = jql_query_max_results_env

    verbose = StepUtility.getEnvironmentVariable('VERBOSE', env)

    current_environment = Environment(
        jira_base_url,
        jira_username,
        jira_api_key,
        action,
        issue,
        issue_project,
        issue_summary,
        issue_description,
        issue_type,
        issue_components,
        issue_customfields,
        existing_comment_id,
        comment_body,
        status,
        jql_query,
        jql_query_max_results,
        verbose)
    return current_environment
示例#2
0
def environment_setup():
    # Grab all of the environment variables
    env = os.environ
    vault_addr = StepUtility.getEnvironmentVariable('VAULT_ADDR', env)
    vault_auth_method = StepUtility.getEnvironmentVariable(
        'VAULT_AUTH_METHOD', env)
    vault_token = StepUtility.getEnvironmentVariable('VAULT_TOKEN', env)
    approle_role_id = StepUtility.getEnvironmentVariable(
        'APPROLE_ROLE_ID', env)
    approle_secret_id = StepUtility.getEnvironmentVariable(
        'APPROLE_SECRET_ID', env)
    vault_client_cert_base64 = StepUtility.getEnvironmentVariable(
        'VAULT_CLIENT_CERT_BASE64', env)
    vault_client_key_base64 = StepUtility.getEnvironmentVariable(
        'VAULT_CLIENT_KEY_BASE64', env)
    mount_point = StepUtility.getEnvironmentVariable('MOUNT_POINT', env)
    vault_kv_version = StepUtility.getEnvironmentVariable(
        'VAULT_KV_VERSION', env)
    new_line_replacement_string = StepUtility.getEnvironmentVariable(
        'NEW_LINE_REPLACEMENT_STRING', env)
    verbose = StepUtility.getEnvironmentVariable('VERBOSE', env)
    current_environment = Environment(
        vault_addr, vault_auth_method, vault_token, approle_role_id,
        approle_secret_id, vault_client_cert_base64, vault_client_key_base64,
        mount_point, vault_kv_version, new_line_replacement_string, verbose)
    return env, current_environment