Exemplo n.º 1
0
def update_build_configuration(environment, product_version_id, art_params,
                               scm_repo_url, scm_revision, artifact_name,
                               project):
    build_config = buildconfigurations.get_build_configuration_by_name(
        name=artifact_name)
    internal_url = build_config.repository_configuration.internal_url
    external_url = build_config.repository_configuration.external_url

    scm_repo_url_no_git_ext = _remove_git_ext(scm_repo_url)

    if _remove_git_ext(internal_url) != scm_repo_url_no_git_ext and (
            external_url is not None
            and _remove_git_ext(external_url) != scm_repo_url_no_git_ext):
        logging.error(
            "SCM URL of existing Build Configuration '%s' cannot be changed" %
            artifact_name)
        return None

    buildconfigurations.update_build_configuration_raw(
        id=build_config.id,
        name=artifact_name,
        project=project.id,
        environment=environment.id,
        scm_repo_url=scm_repo_url,
        scm_revision=scm_revision,
        build_script=get_maven_options(art_params),
        product_version_id=product_version_id,
        generic_parameters=get_generic_parameters(art_params))
    return buildconfigurations.get_build_configuration_raw(id=build_config.id)
Exemplo n.º 2
0
def test_update_build_configuration(mock_envs_api, mock_projects_api, mock_entity, mock_update, mock_get_specific):
    mock = MagicMock()
    mockcontent = MagicMock(content=mock)
    mock_get_specific.return_value = mockcontent
    result = buildconfigurations.update_build_configuration_raw(id=1, build_script='mvn install', project=1, environment=1)
    mock_entity.assert_has_calls([call(mock_projects_api, 1), call(mock_envs_api, 1)])
    mock_get_specific.assert_called_once_with(id=1)
    # object returned by get_specific is appropriately modified
    assert getattr(mock, 'build_script') == 'mvn install'
    mock_update.assert_called_once_with(id=1, body=mock)
    assert result == 'SUCCESS'
Exemplo n.º 3
0
def update_build_configuration(environment, product_version_id, art_params, scm_repo_url, scm_revision, artifact_name, project):
    build_config = buildconfigurations.get_build_configuration_by_name(name=artifact_name)
    internal_url = build_config.repository_configuration.internal_url
    external_url = build_config.repository_configuration.external_url

    scm_repo_url_no_git_ext = _remove_git_ext(scm_repo_url)

    if _remove_git_ext(internal_url) != scm_repo_url_no_git_ext and (external_url is not None and _remove_git_ext(external_url) != scm_repo_url_no_git_ext):
        logging.error("SCM URL of existing Build Configuration '%s' cannot be changed" % artifact_name)
        return None

    buildconfigurations.update_build_configuration_raw(
                                                   id=build_config.id,
                                                   name=artifact_name,
                                                   project=project.id,
                                                   environment=environment.id,
                                                   scm_repo_url=scm_repo_url,
                                                   scm_revision=scm_revision,
                                                   build_script=get_maven_options(art_params),
                                                   product_version_id=product_version_id,
                                                   generic_parameters=get_generic_parameters(art_params))
    return buildconfigurations.get_build_configuration_raw(id=build_config.id)