Skip to content
Snippets Groups Projects
Commit e1ba73b3 authored by Christoph Alt's avatar Christoph Alt
Browse files

added a function to extract gitlab ci variables

parent a5e82b23
No related branches found
No related tags found
No related merge requests found
Pipeline #50978 passed
...@@ -55,6 +55,15 @@ def get_git_infos(repo_path: Union[Path, str], *, commit_key="commit", commit_ms ...@@ -55,6 +55,15 @@ def get_git_infos(repo_path: Union[Path, str], *, commit_key="commit", commit_ms
return {commit_key: commit, commit_msg_key: commit_msg} return {commit_key: commit, commit_msg_key: commit_msg}
def get_git_infos_from_env():
""" Extract commit, commit message, branch and project id from gitlab ci environment."""
return {"commit": os.environ["CI_COMMIT_SHA"],
"commit_message": os.environ["CI_COMMIT_MESSAGE"],
"project_id": os.environ["CI_PROJECT_ID"],
"branch": os.environ["CI_COMMIT_BRANCH"],
}
def file_time_to_sec(file_path) -> int: def file_time_to_sec(file_path) -> int:
return int(os.path.getmtime(file_path)) return int(os.path.getmtime(file_path))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment