Beispiel #1
0
 def create_build_object(self, organization_name, project_name,
                         build_definition_name, pool_name):
     """Create an azure devops build based off a previous definition"""
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name,
                                      creds=self._creds)
     return builder_manager.create_build(build_definition_name, pool_name)
Beispiel #2
0
 def list_build_objects(self, organization_name, project_name):
     """List already running and builds that have already run in an azure devops project"""
     builder_manager = BuilderManager(
         organization_name=organization_name,
         project_name=project_name,
         creds=self._creds
     )
     return builder_manager.list_builds()
Beispiel #3
0
 def list_build_definitions(self, organization_name, project_name):
     """List the azure devops build definitions within a project"""
     builder_manager = BuilderManager(
         organization_name=organization_name,
         project_name=project_name,
         creds=self._creds
     )
     return builder_manager.list_definitions()
 def create_github_build_definition(self, organization_name, project_name,
                                    github_repository,
                                    build_definition_name, pool_name):
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name,
                                      creds=self._creds)
     return builder_manager.create_github_build_definition(
         build_definition_name, pool_name, github_repository)
 def get_build_logs_content_from_statuses(self, organization_name,
                                          project_name, build_id, prev_log,
                                          curr_log):
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name,
                                      creds=self._creds)
     return builder_manager.get_build_logs_content_from_statuses(
         build_id, prev_log, curr_log)
Beispiel #6
0
class TestBuilderManager(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        logging.disable(logging.CRITICAL)

    @classmethod
    def tearDownClass(cls):
        logging.disable(logging.NOTSET)

    def setUp(self):
        self._build_definition_name = "_build_{org}_{proj}_{repo}".format(
            org=ORGANIZATION_NAME,
            proj=PROJECT_NAME,
            repo=REPOSITORY_NAME
        )
        self.builder_manager = BuilderManager(
            organization_name=ORGANIZATION_NAME,
            project_name=PROJECT_NAME,
            repository_name=REPOSITORY_NAME,
            creds=get_credentials()
        )

    @unittest.skipIf(
        not CREATE_DEVOPS_OBJECTS,
        "Set CREATE_DEVOPS_OBJECTS to True if you want to create resources for unit testing"
    )
    def test_create_definition(self):
        definitions = self.builder_manager.list_definitions()

        # Skip if definition already exists
        if self._build_definition_name in [d.name for d in definitions]:
            raise unittest.SkipTest("Build definition exists. No need to create a new build definition.")

        definition = self.builder_manager.create_devops_build_definition(self._build_definition_name, "Default")
        self.assertEqual(definition.name, self._build_definition_name)
        self.assertEqual(definition.process['yamlFilename'], 'azure-pipelines.yml')

    def test_list_definitions(self):
        result = self.builder_manager.list_definitions()
        self.assertIsNotNone(result)
        self.assertGreaterEqual(len(result), 0)

    def test_list_builds(self):
        result = self.builder_manager.list_builds()
        self.assertIsNotNone(result)
        self.assertGreaterEqual(len(result), 0)

    @unittest.skipIf(
        not CREATE_DEVOPS_OBJECTS,
        "Set CREATE_DEVOPS_OBJECTS to True if you want to create resources for unit testing"
    )
    def test_create_build(self):
        result = self.builder_manager.create_build(self._build_definition_name, "Default")
        self.assertIsNotNone(result)
        self.assertEqual(result.definition.name, self._build_definition_name)
Beispiel #7
0
 def create_build_definition(self, organization_name, project_name,
                             repository_name, build_definition_name,
                             pool_name):
     """Create a definition for an azure devops build"""
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name,
                                      repository_name=repository_name,
                                      creds=self._creds)
     return builder_manager.create_definition(
         build_definition_name=build_definition_name, pool_name=pool_name)
Beispiel #8
0
 def setUp(self):
     self._build_definition_name = "_build_{org}_{proj}_{repo}".format(
         org=ORGANIZATION_NAME,
         proj=PROJECT_NAME,
         repo=REPOSITORY_NAME
     )
     self.builder_manager = BuilderManager(
         organization_name=ORGANIZATION_NAME,
         project_name=PROJECT_NAME,
         repository_name=REPOSITORY_NAME,
         creds=get_credentials()
     )
 def list_build_objects(self, organization_name, project_name):
     """List already running and builds that have already run in an azure devops project"""
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name, creds=self._creds)
     return builder_manager.list_builds()
 def create_build_object(self, organization_name, project_name, build_definition_name, pool_name):
     """Create an azure devops build based off a previous definition"""
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name, creds=self._creds)
     return builder_manager.create_build(build_definition_name, pool_name)
 def list_build_definitions(self, organization_name, project_name):
     """List the azure devops build definitions within a project"""
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name, creds=self._creds)
     return builder_manager.list_definitions()
 def create_build_definition(self, organization_name, project_name, repository_name,
                             build_definition_name, pool_name):
     """Create a definition for an azure devops build"""
     builder_manager = BuilderManager(organization_name=organization_name, project_name=project_name,
                                      repository_name=repository_name, creds=self._creds)
     return builder_manager.create_definition(build_definition_name=build_definition_name, pool_name=pool_name)
 def get_build_logs_status(self, organization_name, project_name, build_id):
     builder_manager = BuilderManager(organization_name=organization_name,
                                      project_name=project_name,
                                      creds=self._creds)
     return builder_manager.get_build_logs_status(build_id)