publish also to gitlab
This commit is contained in:
parent
c51d597e56
commit
54f7b1c2da
2 changed files with 44 additions and 11 deletions
|
@ -21,20 +21,18 @@ cache:
|
||||||
- .gradle/wrapper
|
- .gradle/wrapper
|
||||||
- .gradle/caches
|
- .gradle/caches
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- echo "---------- build stage ----------"
|
- 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
|
- ./gradlew assemble
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- build/libs/*.jar
|
- build/libs/*.jar
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
|
@ -61,20 +59,44 @@ test:
|
||||||
junit: build/test-results/test/TEST-*.xml
|
junit: build/test-results/test/TEST-*.xml
|
||||||
|
|
||||||
|
|
||||||
publish-maven-package:
|
package:
|
||||||
stage: publish
|
stage: package
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE != "push"
|
- if: $CI_PIPELINE_SOURCE != "push"
|
||||||
when: never
|
when: never
|
||||||
- if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
|
- if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
|
||||||
script:
|
script:
|
||||||
- ./gradlew -x assemble -x test jar
|
- ./gradlew -x assemble -x test jar
|
||||||
- ./gradlew -x assemble -x test publish
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- build/libs/*.jar
|
- 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:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
rules:
|
rules:
|
||||||
|
|
19
build.gradle
19
build.gradle
|
@ -182,6 +182,17 @@ publishing {
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
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 {
|
maven {
|
||||||
name = "meissa"
|
name = "meissa"
|
||||||
url = uri("https://repo.prod.meissa.de/api/packages/meissa/maven")
|
url = uri("https://repo.prod.meissa.de/api/packages/meissa/maven")
|
||||||
|
@ -189,12 +200,12 @@ publishing {
|
||||||
credentials(HttpHeaderCredentials) {
|
credentials(HttpHeaderCredentials) {
|
||||||
name = "Authorization"
|
name = "Authorization"
|
||||||
if (System.getenv("CI_JOB_TOKEN") != null) {
|
if (System.getenv("CI_JOB_TOKEN") != null) {
|
||||||
def tok = System.getenv("RELEASE_TOKEN")
|
def tokenFromEnv = System.getenv("RELEASE_TOKEN")
|
||||||
if (tok == null) {
|
if (tokenFromEnv == null) {
|
||||||
println "Error: RELEASE_TOKEN not found"
|
println "Error: RELEASE_TOKEN not found"
|
||||||
} else {
|
} else {
|
||||||
value = "token " + tok
|
value = "token " + tokenFromEnv
|
||||||
println "RELEASE_TOKEN found - " + (10 < tok.length())
|
println "RELEASE_TOKEN found - "
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// use project-property (define e.g. in "~/.gradle/gradle.properties") when not running in ci
|
// use project-property (define e.g. in "~/.gradle/gradle.properties") when not running in ci
|
||||||
|
|
Loading…
Reference in a new issue