Пример #1
0
    def add_build_information(self, data):
        data[pipeline_data.
             PACKAGE_JSON]["se.kth.gitBranch"] = environment.get_git_branch()
        data[pipeline_data.PACKAGE_JSON][
            "se.kth.gitCommit"] = environment.get_git_commit_clamped()
        data[pipeline_data.
             PACKAGE_JSON]["se.kth.buildDate"] = environment.get_time()

        return data
Пример #2
0
def slugify_branch():
    """
    Take some name (any string) and return a version-slug-safe variant of it.
    """
    # This could be done better with an external dependency,
    # but branch-names are probably ascii anyway.
    # "feature/slånbärsöl" will become "feature.sl.nb.rs.l", so it errs on the safe side.
    # If the result is an empty string, substitute "unknown"
    return re.sub('[^a-z0-9]+', '.',
                  environment.get_git_branch().lower()).strip('.') or 'unknown'
    def get_build_environment(self, data):

        return {
            "gitBranch": environment.get_git_branch(),
            "gitCommit": environment.get_git_commit(),
            "gitUrl": environment.get_git_url(),
            "buildNumber": environment.get_build_number(),
            "buildDate": environment.get_time(),
            "version": data[pipeline_data.PACKAGE_JSON]["version"]
        }
Пример #4
0
def is_main_branch():

    branch = environment.get_git_branch()

    if 'master' in branch:
        return True

    if 'main' in branch:
        return True

    return False
Пример #5
0
    def add_build_information(self, data):
        data[pipeline_data.PACKAGE_JSON]["se.kth.gitBranch"] = environment.get_git_branch()
        data[pipeline_data.PACKAGE_JSON]["se.kth.gitCommit"] = git.get_commit_clamped()
        data[pipeline_data.PACKAGE_JSON]["se.kth.buildDate"] = environment.get_time()

        self.log.info('Added information to package.json')
        self.log.info(f'se.kth.gitBranch: {data[pipeline_data.PACKAGE_JSON]["se.kth.gitBranch"]}')
        self.log.info(f'se.kth.gitCommit: {data[pipeline_data.PACKAGE_JSON]["se.kth.gitCommit"]}')
        self.log.info(f'se.kth.buildDate: {data[pipeline_data.PACKAGE_JSON]["se.kth.buildDate"]}')

        return data
    def get_build_environment(self, data):

        return {
            "gitBranch":
            environment.get_git_branch(),
            "gitCommit":
            environment.get_git_commit(),
            "gitUrl":
            environment.get_git_url(),
            "jenkinsBuild":
            environment.get_build_number(),
            "jenkinsBuildDate":
            environment.get_time(),
            "dockerName":
            data[pipeline_data.IMAGE_NAME],
            "dockerVersion":
            data[pipeline_data.IMAGE_VERSION],
            "dockerImage":
            image_version_util.prepend_registry(
                image_version_util.get_image(data))
        }
Пример #7
0
def branch_starts_with(pattern):
    if pattern is None:
        return False
        
    return str(environment.get_git_branch()).startswith(pattern)