Skip to content

Commit

Permalink
Merge pull request #877 from pablomedeiross/feat/branch-version-by-gi…
Browse files Browse the repository at this point in the history
…tlab

feature: including new logic to handle versions from gitlab tags and …
  • Loading branch information
larsgrefer committed Sep 3, 2023
2 parents b1a2281 + b76a556 commit 8516eed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ else if (GitUtil.isCircleCi(providerFactory)) {
logger.lifecycle("Using CIRCLE_BRANCH '{}' as version: {}", circleBranch, version);
return version;
}

} else if (GitUtil.isGitLab(providerFactory)) {
Provider<String> gitLabTag = providerFactory.environmentVariable("CI_COMMIT_TAG");
if (gitLabTag.isPresent()) {
String version = resolveTagVersion(gitLabTag.get().trim());
logger.lifecycle("Using CI_COMMIT_TAG '{}' as version: {}", gitLabTag, version);
return version;
}

Provider<String> gitLabBranch = providerFactory.environmentVariable("CI_COMMIT_BRANCH");
if (gitLabBranch.isPresent()) {
String version = resolveBranchVersion(gitLabBranch.get());
logger.lifecycle("Using CI_COMMIT_BRANCH '{}' as version: {}", gitLabBranch, version);
return version;
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public boolean isJenkins(ProviderFactory providerFactory) {
return providerFactory.environmentVariable("JENKINS_HOME").isPresent();
}

public boolean isGitLab(ProviderFactory providerFactory) {
return providerFactory.environmentVariable("GITLAB_CI").isPresent();
}

public String getSha(Project project) {
if (isGithubActions(project.getProviders())) {
return project.getProviders().environmentVariable("GITHUB_SHA").get();
Expand Down

0 comments on commit 8516eed

Please sign in to comment.