Initial commit

This commit is contained in:
David Hiendl 2022-09-26 16:00:41 +02:00
commit 27dbe07bd2
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
def addGitlabGroupRepository(RepositoryHandler handler, String groupName, String groupId) {
handler.maven {
name "Gitlab Group - $groupName"
url = "${gitlabCiApiUrl}/groups/${groupId}/-/packages/maven"
setGitlabRepoAuth(it)
}
}
def addGitlabPublishingRepository(RepositoryHandler handler) {
handler.maven {
name = "Gitlab_Project"
url = "${gitlabCiApiUrl}/projects/${gitlabCiProjectId}/packages/maven"
setGitlabRepoAuth(it)
}
}
def setGitlabRepoAuth(MavenArtifactRepository maven) {
if (System.getenv("CI_JOB_TOKEN") != null) {
maven.credentials(HttpHeaderCredentials) {
name = 'Job-Token'
value = System.getenv("CI_JOB_TOKEN")
}
} else if (gitlabPrivateToken != null) {
maven.credentials(HttpHeaderCredentials) {
name = 'Private-Token'
value = gitlabPrivateToken
}
} else {
throw Exception("No gitlab maven repository auth configured")
}
maven.authentication {
header(HttpHeaderAuthentication)
}
}
// Export methods by turning them into closures
ext {
setGitlabRepoAuth = this.&setGitlabRepoAuth
addGitlabPublishingRepository = this.&addGitlabPublishingRepository
addGitlabGroupRepository = this.&addGitlabGroupRepository
}

0
gradle/README.md Normal file
View File