Commit 6395a421 authored by Julian Stirling's avatar Julian Stirling 🐧
Browse files

Build pipeline use multiline pipline hashes on if merged result

parent a6677b57
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ def write_ninja_file(build_dir):
        writer.openscad("nut_trap_test.stl", "test_pieces/nut_trap_test.scad")
        writer.openscad("leg_test.stl", "test_pieces/leg_test.scad")
        writer.openscad("rms_thread.stl", "test_pieces/rms_thread.scad")
        open_v_string = ["Open", "Actuators"]
        open_v_string = "Open\\nActuators"
        writer.openscad(
            "test_pieces/main_body_open_actuators.stl",
            "test_pieces/main_body_open_actuators.scad",
+20 −2
Original line number Diff line number Diff line
@@ -59,9 +59,12 @@ def version_string(force_clean, check_env=True):
    The version string for the microscope.
    """
    if check_env:
        # First check environment vars for CI version string
        ci_version_string = os.getenv("CI_VERSION_STRING", None)
        if ci_version_string is not None:
            return ci_version_string

    # Set to custom if not clean
    if not _repo_is_clean():
        if force_clean:
            print("Warning! Git repository is not clean:")
@@ -70,16 +73,31 @@ def version_string(force_clean, check_env=True):
            sys.exit(1)
        return "Custom"

    # Next priority is the tag.
    tag = _get_commit_tag()
    if _is_release(tag):
        return tag

    # Next priority is pipeline ID if in a merged_result pipeline
    event_type = os.getenv("CI_MERGE_REQUEST_EVENT_TYPE", None)
    print(f"Merge Event Type: {event_type}")
    pipeline_id = os.getenv("CI_PIPELINE_ID", None)
    if pipeline_id is None:
    print(f"Pipeline ID: {pipeline_id}")
    # If we are in a merged result pipeline then the hash isn't in the repo.
    if event_type == "merged_result" and pipeline_id is not None:
        # Pint the pipeline id on the main body
        if len(pipeline_id) <= 10:
            return f"Pipeline\\n{pipeline_id}"
        # With a fallback in case the ids get longer
        return f"Pipe{pipeline_id[0:2]}-\\n{pipeline_id[2:]}"

    # Finally use hash (unless it is None)
    commit_hash = _get_commit_hash()
    if commit_hash is None:
        if force_clean:
            sys.exit(1)
        return "Custom"
    return ["Pipeline", pipeline_id[0:10]]
    return commit_hash[0:7]

def commit_string(force_clean, check_env=True):
    """