Skip to content

Commit

Permalink
Initially adapt gitlabMavenRepository to make it work in GitLab CI/CD
Browse files Browse the repository at this point in the history
The adapted code is not tested yet.
  • Loading branch information
ShreckYe committed Nov 23, 2024
1 parent de1baa3 commit 990345e
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ fun Project.gitlabMavenRepository(repositoryHandler: RepositoryHandler, nameArg:
url = uri(urlArg)
name = nameArg
credentials(HttpHeaderCredentials::class) {
name = "Private-Token"
value = findProperty("gitLabPrivateToken") as String?
val gitLabPrivateToken: String? by properties
val ciJobToken: String? = System.getenv("CI_JOB_TOKEN")
if (gitLabPrivateToken !== null) {
name = "Private-Token"
value = gitLabPrivateToken

if (ciJobToken !== null)
logger.warn("Both the private token and the CI Job token are specified for the GitLab Maven package registry ${this@maven} and the private token takes precedence.")
} else if (ciJobToken !== null) {
name = "Job-Token"
value = ciJobToken
}
}
authentication {
create("header", HttpHeaderAuthentication::class)
Expand Down

0 comments on commit 990345e

Please sign in to comment.