def manual_start(self, run_parameters=None): config = self.config source = config["build_source"] try: gh_client = self._get_client() repo = gh_client.get_repo(source) default_branch = repo.default_branch except GithubException as ghe: msg = GithubBuildTrigger._get_error_message(ghe, "Unable to start build trigger") raise TriggerStartException(msg) def get_branch_sha(branch_name): try: branch = repo.get_branch(branch_name) return branch.commit.sha except GithubException: raise TriggerStartException("Could not find branch in repository") def get_tag_sha(tag_name): tags = {tag.name: tag for tag in repo.get_tags()} if not tag_name in tags: raise TriggerStartException("Could not find tag in repository") return tags[tag_name].commit.sha # Find the branch or tag to build. (commit_sha, ref) = determine_build_ref( run_parameters, get_branch_sha, get_tag_sha, default_branch ) metadata = GithubBuildTrigger._build_metadata_for_commit(commit_sha, ref, repo) return self.prepare_build(metadata, is_manual=True)
def get_tag_sha(tag_name): try: tag = gl_project.tags.get(tag_name) except gitlab.GitlabGetError: raise TriggerStartException("Could not find tag in repository") return tag.attributes["commit"]["id"]
def get_tag_sha(tag_name): # Lookup the commit SHA for the tag. (result, data, _) = repository.get_tag(tag_name) if not result: raise TriggerStartException('Could not find tag in repository') return data['target']['hash']
def get_branch_sha(branch_name): try: branch = gl_project.branches.get(branch_name) except gitlab.GitlabGetError: raise TriggerStartException("Could not find branch in repository") return branch.attributes["commit"]["id"]
def manual_start(self, run_parameters=None): gl_client = self._get_authorized_client() gl_project = gl_client.projects.get(self.config["build_source"]) if not gl_project: raise TriggerStartException("Could not find repository") def get_tag_sha(tag_name): try: tag = gl_project.tags.get(tag_name) except gitlab.GitlabGetError: raise TriggerStartException("Could not find tag in repository") return tag.attributes["commit"]["id"] def get_branch_sha(branch_name): try: branch = gl_project.branches.get(branch_name) except gitlab.GitlabGetError: raise TriggerStartException("Could not find branch in repository") return branch.attributes["commit"]["id"] # Find the branch or tag to build. (commit_sha, ref) = determine_build_ref( run_parameters, get_branch_sha, get_tag_sha, gl_project.attributes["default_branch"] ) metadata = self.get_metadata_for_commit(commit_sha, ref, gl_project) return self.prepare_build(metadata, is_manual=True)
def get_branch_sha(branch_name): # Lookup the commit SHA for the branch. (result, data, _) = repository.get_branch(branch_name) if not result: raise TriggerStartException("Could not find branch in repository") return data["target"]["hash"]
def get_branch_sha(branch_name): try: branch = repo.get_branch(branch_name) return branch.commit.sha except GithubException: raise TriggerStartException( "Could not find branch in repository")
def manual_start(self, run_parameters=None): # commit_sha is the only required parameter commit_sha = run_parameters.get('commit_sha') if commit_sha is None: raise TriggerStartException('missing required parameter') config = self.config metadata = { 'commit': commit_sha, 'git_url': config['build_source'], } try: return self.prepare_build(metadata, is_manual=True) except ValidationError as ve: raise TriggerStartException(ve.message)
def manual_start(self, run_parameters=None): # commit_sha is the only required parameter commit_sha = run_parameters.get("commit_sha") if commit_sha is None: raise TriggerStartException("missing required parameter") config = self.config metadata = { "commit": commit_sha, "git_url": config["build_source"], } try: return self.prepare_build(metadata, is_manual=True) except ValidationError as ve: raise TriggerStartException(ve.message)
def manual_start(self, run_parameters=None): run_parameters = run_parameters or {} repository = self._get_repository_client() bitbucket_client = self._get_authorized_client() def get_branch_sha(branch_name): # Lookup the commit SHA for the branch. (result, data, _) = repository.get_branch(branch_name) if not result: raise TriggerStartException( 'Could not find branch in repository') return data['target']['hash'] def get_tag_sha(tag_name): # Lookup the commit SHA for the tag. (result, data, _) = repository.get_tag(tag_name) if not result: raise TriggerStartException('Could not find tag in repository') return data['target']['hash'] def lookup_author(email_address): (result, data, _) = bitbucket_client.accounts().get_profile(email_address) return data if result else None # Find the branch or tag to build. default_branch = self._get_default_branch(repository) (commit_sha, ref) = determine_build_ref(run_parameters, get_branch_sha, get_tag_sha, default_branch) # Lookup the commit SHA in BitBucket. (result, commit_info, _) = repository.changesets().get(commit_sha) if not result: raise TriggerStartException('Could not lookup commit SHA') # Return a prepared build for the commit. repository_name = '%s/%s' % (repository.namespace, repository.repository_name) metadata = get_transformed_commit_info(commit_info, ref, default_branch, repository_name, lookup_author) return self.prepare_build(metadata, is_manual=True)
def get_tag_sha(tag_name): tags = {tag.name: tag for tag in repo.get_tags()} if not tag_name in tags: raise TriggerStartException("Could not find tag in repository") return tags[tag_name].commit.sha