Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils): more gitlab build context support #568

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion packages/utils/src/build-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function getGitRemote() {
const envHash = getEnvVarIfSet([
// Manual override
'LHCI_BUILD_CONTEXT__GIT_REMOTE',
// GitLab CI
'CI_REPOSITORY_URL',
]);
if (envHash) return envHash;

Expand Down Expand Up @@ -90,6 +92,8 @@ function getCommitTime(hash) {
const envHash = getEnvVarIfSet([
// Manual override
'LHCI_BUILD_CONTEXT__COMMIT_TIME',
// GitLab CI
'CI_COMMIT_TIMESTAMP',
]);
if (envHash) return envHash;

Expand Down Expand Up @@ -193,6 +197,8 @@ function getCommitMessage(hash = 'HEAD') {
const envHash = getEnvVarIfSet([
// Manual override
'LHCI_BUILD_CONTEXT__COMMIT_MESSAGE',
// GitLab CI
'CI_COMMIT_MESSAGE',
]);
if (envHash) return envHash;

Expand All @@ -217,6 +223,8 @@ function getAuthor(hash = 'HEAD') {
const envHash = getEnvVarIfSet([
// Manual override
'LHCI_BUILD_CONTEXT__AUTHOR',
// GitLab CI: https://gitlab.com/gitlab-org/gitlab/-/issues/284079
'CI_COMMIT_AUTHOR',
]);
if (envHash) return envHash;

Expand Down Expand Up @@ -325,8 +333,10 @@ function getAncestorHash(hash, baseBranch) {
const envHash = getEnvVarIfSet([
// Manual override
'LHCI_BUILD_CONTEXT__ANCESTOR_HASH',
// GitLab CI
'CI_COMMIT_BEFORE_SHA',
]);
if (envHash) return envHash;
if (envHash && envHash !== '0000000000000000000000000000000000000000') return envHash;

return getCurrentBranch() === baseBranch
? getAncestorHashForBase(hash)
Expand Down