publish also to gitlab

This commit is contained in:
ansgarz 2023-06-30 13:56:31 +02:00
parent c51d597e56
commit 54f7b1c2da
2 changed files with 44 additions and 11 deletions

View file

@ -21,20 +21,18 @@ cache:
- .gradle/wrapper
- .gradle/caches
build:
stage: build
script:
- echo "---------- build stage ----------"
- apt-get update -y
- apt-get install -y iputils-ping ssh
- ping -c 2 repo.prod.meissa.de
- ssh-keyscan repo.prod.meissa.de
- ./gradlew assemble
artifacts:
paths:
- build/libs/*.jar
expire_in: 1 week
test:
stage: test
image: docker:latest
@ -61,20 +59,44 @@ test:
junit: build/test-results/test/TEST-*.xml
publish-maven-package:
stage: publish
package:
stage: package
rules:
- if: $CI_PIPELINE_SOURCE != "push"
when: never
- if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
script:
- ./gradlew -x assemble -x test jar
- ./gradlew -x assemble -x test publish
artifacts:
paths:
- build/libs/*.jar
publish-maven-package-to-gitlab:
stage: publish
rules:
- if: $CI_PIPELINE_SOURCE != "push"
when: never
- if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
script:
- ./gradlew -x assemble -x test publishLibraryPublicationToGitlabRepository
publish-maven-package-to-meissa:
stage: publish
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE != "push"
when: never
- if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
script:
- apt-get update -y
- apt-get install -y iputils-ping ssh
- ping -c 2 repo.prod.meissa.de
- ssh-keyscan repo.prod.meissa.de
- ./gradlew -x assemble -x test publishLibraryPublicationToMeissaRepository
release:
stage: release
rules:

View file

@ -182,6 +182,17 @@ publishing {
}
repositories {
maven {
name = "gitlab"
url = "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Job-Token"
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
maven {
name = "meissa"
url = uri("https://repo.prod.meissa.de/api/packages/meissa/maven")
@ -189,12 +200,12 @@ publishing {
credentials(HttpHeaderCredentials) {
name = "Authorization"
if (System.getenv("CI_JOB_TOKEN") != null) {
def tok = System.getenv("RELEASE_TOKEN")
if (tok == null) {
def tokenFromEnv = System.getenv("RELEASE_TOKEN")
if (tokenFromEnv == null) {
println "Error: RELEASE_TOKEN not found"
} else {
value = "token " + tok
println "RELEASE_TOKEN found - " + (10 < tok.length())
value = "token " + tokenFromEnv
println "RELEASE_TOKEN found - "
}
} else {
// use project-property (define e.g. in "~/.gradle/gradle.properties") when not running in ci