Merge pull request #8 from Azure/github_support

GitHub support
This commit is contained in:
Oliver Dolk 2019-02-13 11:18:10 -08:00 коммит произвёл GitHub
Родитель 5959c4ff61 8ef917f241
Коммит 60da811261
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 21 добавлений и 16 удалений

Просмотреть файл

@ -1 +1 @@
include *.jinja
include *.jinja

Просмотреть файл

@ -58,5 +58,5 @@ class BaseManager(object):
service_endpoints = self._service_endpoint_client.get_service_endpoints(project.id)
github_endpoint = next((endpoint for endpoint in service_endpoints if endpoint.type == "github"), None)
repositories = self._build_client.list_repositories(project.id, 'github', github_endpoint.id)
repository_match = next((repository for repository in repositories.repositories if repository.name == name), None)
repository_match = next((repository for repository in repositories.repositories if repository.full_name == name), None)
return repository_match

Просмотреть файл

@ -6,7 +6,7 @@
import vsts.build.v4_1.models as build_models
from ..base.base_manager import BaseManager
from ..pool.pool_manager import PoolManager
import time
class BuilderManager(BaseManager):
""" Manage DevOps Builds
@ -34,7 +34,6 @@ class BuilderManager(BaseManager):
github_properties = repository.properties
build_repository = build_models.build_repository.BuildRepository(default_branch="master", id=repository.id, properties=github_properties,
name=repository.full_name, type="GitHub", url=repository.properties['cloneUrl'])
else:
repository = self._get_repository_by_name(project, self._repository_name)
build_repository = build_models.build_repository.BuildRepository(default_branch="master", id=repository.id,

Просмотреть файл

@ -54,7 +54,9 @@ class ReleaseManager(BaseManager):
settings_str = ""
for setting in settings:
settings_str += (setting[0] + "='" + setting[1] + "'")
workflowtasks.append(self._app_settings_task_customized(service_endpoint.id, functionapp_name, resource_name, settings_str))
# Check that settings were actually set otherwise we don't want to use the task
if settings_str != "":
workflowtasks.append(self._app_settings_task_customized(service_endpoint.id, functionapp_name, resource_name, settings_str))
deploy_phases = self._get_deploy_phases(deployment_input, workflowtasks, phase_inputs)

Просмотреть файл

@ -87,6 +87,11 @@ class RepositoryManager(BaseManager):
succeeded = True
return models.repository_response.RepositoryResponse(message, succeeded)
def setup_github_repository(self):
check_call('git add -A'.split(), stdout=DEVNULL, stderr=STDOUT)
check_call(["git", "commit", "-a", "-m", "\"creating functions app\""], stdout=DEVNULL, stderr=STDOUT)
check_call('git push'.split(), stdout=DEVNULL, stderr=STDOUT)
def _repository_exists(self):
"""Helper to see if gitfile exists"""
return bool(os.path.exists('.git'))

Просмотреть файл

@ -28,9 +28,9 @@ class ServiceEndpointManager(BaseManager):
auth = models.endpoint_authorization.EndpointAuthorization(
parameters={
"AccessToken": access_token
"accessToken": access_token
},
scheme="OAuth"
scheme="PersonalAccessToken"
)
service_endpoint = models.service_endpoint.ServiceEndpoint(

Просмотреть файл

@ -7,7 +7,7 @@
from setuptools import setup, find_packages
NAME = "azure-functions-devops-build"
VERSION = "0.0.6"
VERSION = "0.0.11"
# To install the library, run the following
#
@ -16,19 +16,19 @@ VERSION = "0.0.6"
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
REQUIRES = ["msrest>=0.2.0",
"vsts>=0.1.25",
"jinja2>=2.10"]
REQUIRES = ["msrest",
"vsts",
"jinja2"]
setup(
name=NAME,
version=VERSION,
description="Python package for integrating azure functions with azure devops. Specifically made for the Azure Cli",
author_email="t-oldolk@microsoft.com",
url="https://github.com/dolko/azure-devops-build-manager",
url="https://github.com/Azure/azure-functions-devops-build",
keywords=["Microsoft", "Azure Devops", "Azure Functions"],
install_requires=REQUIRES,
packages=find_packages(),
packages=find_packages(exclude=["tests.*", "tests"]),
include_package_data=True,
long_description="""\
"""

Просмотреть файл

@ -11,8 +11,8 @@ from azure_functions_devops_build.constants import LINUX_CONSUMPTION, LINUX_DEDI
CREATE_DEVOPS_OBJECTS = False
# Specify the name of your already created devops objects
ORGANIZATION_NAME = 'ollys-hck'
PROJECT_NAME = 'cmd-test-2'
ORGANIZATION_NAME = 'build-release-yamls'
PROJECT_NAME = 'github_test'
SERVICE_ENDPOINT_NAME = ORGANIZATION_NAME + PROJECT_NAME
REPOSITORY_NAME = PROJECT_NAME
BUILD_DEFINITION_NAME = PROJECT_NAME

Просмотреть файл

@ -25,6 +25,5 @@ class TestServiceEndpointManager(unittest.TestCase):
service_endpoint_manager = ServiceEndpointManager(organization_name=ORGANIZATION_NAME, project_name=PROJECT_NAME, creds=creds)
endpoint = service_endpoint_manager.create_service_endpoint(SERVICE_ENDPOINT_NAME)
if __name__ == '__main__':
unittest.main()