Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Alt
cb-util
Commits
e1ba73b3
Commit
e1ba73b3
authored
2 years ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
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
2 years ago
Stage: test
Stage: deploy
Stage: trigger
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cbutil/util.py
+9
-0
9 additions, 0 deletions
cbutil/util.py
with
9 additions
and
0 deletions
cbutil/util.py
+
9
−
0
View file @
e1ba73b3
...
@@ -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
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment