Deploy develop branch and use environment variables to pass gradle properties

This commit is contained in:
Sebastian Sdorra
2021-01-14 15:08:10 +01:00
parent cbb95ad107
commit b53a7673e3

28
Jenkinsfile vendored
View File

@@ -86,13 +86,15 @@ pipeline {
stage('Deployment') { stage('Deployment') {
when { when {
branch pattern: 'release/*', comparator: 'GLOB' anyOf {
// TODO or develop branch pattern: 'release/*', comparator: 'GLOB'
branch 'develop'
}
expression { return isBuildSuccess() } expression { return isBuildSuccess() }
} }
steps { steps {
withPublishProperies { withPublishEnivronment {
gradle "publish ${PUBLISH_PROPERTIES}" gradle "publish"
} }
} }
} }
@@ -181,19 +183,15 @@ void isBuildSuccess() {
return currentBuild.result == null || currentBuild.result == 'SUCCESS' return currentBuild.result == null || currentBuild.result == 'SUCCESS'
} }
void withPublishProperies(Closure<Void> closure) { void withPublishEnivronment(Closure<Void> closure) {
withCredentials([ withCredentials([
usernamePassword(credentialsId: 'maven.scm-manager.org', passwordVariable: 'PACKAGES_PASSWORD', usernameVariable: 'PACKAGES_USERNAME'), usernamePassword(credentialsId: 'maven.scm-manager.org', usernameVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerUsername', passwordVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerPassword'),
usernamePassword(credentialsId: 'hub.docker.com-cesmarvin', passwordVariable: 'DOCKER_PASSWORD', usernameVariable: 'DOCKER_USERNAME'), usernamePassword(credentialsId: 'hub.docker.com-cesmarvin', usernameVariable: 'ORG_GRADLE_PROJECT_dockerUsername', passwordVariable: 'ORG_GRADLE_PROJECT_dockerPassword'),
string(credentialsId: 'cesmarvin_npm_token', variable: 'NPM_TOKEN'), string(credentialsId: 'cesmarvin_npm_token', variable: 'ORG_GRADLE_PROJECT_npmToken'),
file(credentialsId: 'oss-gpg-secring', variable: 'GPG_KEYRING'), file(credentialsId: 'oss-gpg-secring', variable: 'ORG_GRADLE_PROJECT_signing.secretKeyRingFile'),
usernamePassword(credentialsId: 'oss-keyid-and-passphrase', usernameVariable: 'GPG_KEY_ID', passwordVariable: 'GPG_KEY_PASSPHRASE') usernamePassword(credentialsId: 'oss-keyid-and-passphrase', usernameVariable: 'ORG_GRADLE_PROJECT_signing.keyId', passwordVariable: 'ORG_GRADLE_PROJECT_signing.password')
]) { ]) {
String properties = "-PpackagesScmManagerUsername=${PACKAGES_USERNAME} -PpackagesScmManagerPassword=${PACKAGES_PASSWORD}" withEnv(["ORG_GRADLE_PROJECT_npmEmail=cesmarvin@cloudogu.com"]) {
properties += " -PdockerUsername=${DOCKER_USERNAME} -PdockerPassword=${DOCKER_PASSWORD}"
properties += " -PnpmEmail=cesmarvin@cloudogu.com -PnpmToken=${NPM_TOKEN}"
properties += " -Psigning.secretKeyRingFile=${GPG_KEYRING} -Psigning.keyId=${GPG_KEY_ID} -Psigning.password=${GPG_KEY_PASSPHRASE}"
withEnv(["PUBLISH_PROPERTIES=\"${properties}\""]) {
closure.call() closure.call()
} }
} }