2018-05-31 12:34:34 +02:00
|
|
|
#!groovy
|
2021-01-13 13:30:44 +01:00
|
|
|
pipeline {
|
2018-07-12 11:06:54 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
options {
|
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '10'))
|
2020-03-11 11:05:54 +01:00
|
|
|
disableConcurrentBuilds()
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
2018-05-31 12:34:34 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
agent {
|
|
|
|
|
docker {
|
2021-01-14 20:17:18 +01:00
|
|
|
image 'scmmanager/java-build:11.0.9.1_1-2'
|
|
|
|
|
args '-v /var/run/docker.sock:/var/run/docker.sock --group-add 998'
|
2021-01-13 13:30:44 +01:00
|
|
|
label 'docker'
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-31 12:34:34 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
environment {
|
|
|
|
|
HOME = "${env.WORKSPACE}"
|
|
|
|
|
SONAR_USER_HOME = "${env.WORKSPACE}/.sonar"
|
|
|
|
|
}
|
2018-05-31 12:34:34 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stages {
|
2018-05-31 12:34:34 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Set Version') {
|
|
|
|
|
when {
|
|
|
|
|
branch pattern: 'release/*', comparator: 'GLOB'
|
2018-09-12 18:01:00 +02:00
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
steps {
|
|
|
|
|
// read version from branch, set it and commit it
|
2021-01-29 12:06:17 +01:00
|
|
|
gradle "setVersion -PnewVersion=${releaseVersion}"
|
2021-01-13 13:30:44 +01:00
|
|
|
sh "git add gradle.properties lerna.json '**.json'"
|
|
|
|
|
commit "Release version ${releaseVersion}"
|
|
|
|
|
|
|
|
|
|
// fetch all remotes from origin
|
|
|
|
|
sh 'git config --replace-all "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"'
|
|
|
|
|
sh 'git fetch --all'
|
|
|
|
|
|
|
|
|
|
// checkout, reset and merge
|
|
|
|
|
sh 'git checkout master'
|
|
|
|
|
sh 'git reset --hard origin/master'
|
|
|
|
|
sh "git merge --ff-only ${env.BRANCH_NAME}"
|
|
|
|
|
|
|
|
|
|
// set tag
|
|
|
|
|
tag releaseVersion
|
2020-03-11 11:05:54 +01:00
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
2020-03-11 11:05:54 +01:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Build') {
|
|
|
|
|
steps {
|
|
|
|
|
// build without tests
|
2021-01-14 08:29:36 +01:00
|
|
|
gradle "-xtest build"
|
2018-09-12 18:01:00 +02:00
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
2018-05-31 12:34:34 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Check') {
|
|
|
|
|
steps {
|
2021-05-11 14:09:09 +02:00
|
|
|
withCheckEnvironment {
|
|
|
|
|
gradle 'check'
|
|
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
junit allowEmptyResults: true, testResults: '**/build/test-results/test/TEST-*.xml,**/build/test-results/tests/test/TEST-*.xml,**/build/jest-reports/TEST-*.xml'
|
2018-07-11 18:07:26 +02:00
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
2018-09-24 13:03:02 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
// in parallel with check?
|
|
|
|
|
stage('Integration Tests') {
|
|
|
|
|
steps {
|
2021-01-20 11:26:40 +01:00
|
|
|
// TODO remove obligatory rerun flag when flappy tests have been fixed
|
|
|
|
|
gradle '-PrerunIntegrationTests integrationTest'
|
2021-01-13 13:30:44 +01:00
|
|
|
junit allowEmptyResults: true, testResults: 'scm-it/build/test-results/javaIntegrationTests/*.xml,scm-ui/build/reports/e2e/*.xml'
|
|
|
|
|
archiveArtifacts allowEmptyArchive: true, artifacts: 'scm-ui/e2e-tests/cypress/videos/*.mp4'
|
|
|
|
|
archiveArtifacts allowEmptyArchive: true, artifacts: 'scm-ui/e2e-tests/cypress/screenshots/**/*.png'
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-30 11:25:01 +01:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('SonarQube') {
|
|
|
|
|
steps {
|
|
|
|
|
sh 'git config --replace-all "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"'
|
2021-01-14 13:39:26 +01:00
|
|
|
sh 'git fetch origin develop'
|
2021-01-13 13:30:44 +01:00
|
|
|
script {
|
|
|
|
|
withSonarQubeEnv('sonarcloud.io-scm') {
|
2021-02-23 10:22:37 +01:00
|
|
|
String parameters = ' -Dsonar.organization=scm-manager'
|
|
|
|
|
if (env.CHANGE_ID) {
|
|
|
|
|
parameters += ' -Dsonar.pullrequest.provider=GitHub'
|
|
|
|
|
parameters += ' -Dsonar.pullrequest.github.repository=scm-manager/scm-manager'
|
|
|
|
|
parameters += " -Dsonar.pullrequest.key=${env.CHANGE_ID}"
|
|
|
|
|
parameters += " -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
|
|
|
|
|
parameters += " -Dsonar.pullrequest.base=${env.CHANGE_TARGET}"
|
|
|
|
|
} else {
|
|
|
|
|
parameters += " -Dsonar.branch.name=${env.BRANCH_NAME}"
|
|
|
|
|
if (env.BRANCH_NAME != "develop") {
|
|
|
|
|
parameters += " -Dsonar.branch.target=develop"
|
|
|
|
|
}
|
2020-03-11 11:05:54 +01:00
|
|
|
}
|
2021-01-14 08:29:36 +01:00
|
|
|
gradle "sonarqube ${parameters}"
|
2020-05-26 09:47:38 +02:00
|
|
|
}
|
2020-05-10 21:47:35 +02:00
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-03-11 11:05:54 +01:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Deployment') {
|
|
|
|
|
when {
|
2021-01-14 15:08:10 +01:00
|
|
|
anyOf {
|
|
|
|
|
branch pattern: 'release/*', comparator: 'GLOB'
|
|
|
|
|
branch 'develop'
|
|
|
|
|
}
|
2021-01-13 13:30:44 +01:00
|
|
|
expression { return isBuildSuccess() }
|
|
|
|
|
}
|
|
|
|
|
steps {
|
2021-01-14 15:08:10 +01:00
|
|
|
withPublishEnivronment {
|
2021-02-08 13:21:28 +01:00
|
|
|
gradle "-PenablePackaging publish"
|
2020-05-25 13:53:44 +02:00
|
|
|
}
|
2021-10-08 11:15:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Update tap') {
|
|
|
|
|
when {
|
|
|
|
|
branch pattern: 'release/*', comparator: 'GLOB'
|
|
|
|
|
expression { return isBuildSuccess() }
|
|
|
|
|
}
|
|
|
|
|
steps {
|
2021-10-07 14:41:34 +02:00
|
|
|
build wait: false, propagate: false, job: 'scm-manager-github/homebrew-tap/master', parameters: [
|
|
|
|
|
string(name: 'Version', value: getReleaseVersion())
|
|
|
|
|
]
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-03-11 11:05:54 +01:00
|
|
|
|
2021-01-18 12:05:47 +01:00
|
|
|
stage('Presentation Environment') {
|
|
|
|
|
when {
|
|
|
|
|
branch 'develop'
|
|
|
|
|
expression { return isBuildSuccess() }
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
script {
|
|
|
|
|
def imageVersion = readFile 'scm-packaging/docker/build/docker.tag'
|
|
|
|
|
|
|
|
|
|
build job: 'scm-manager/next-scm.cloudogu.com', propagate: false, wait: false, parameters: [
|
|
|
|
|
string(name: 'imageTag', value: imageVersion)
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Push Tag') {
|
|
|
|
|
when {
|
|
|
|
|
branch pattern: 'release/*', comparator: 'GLOB'
|
|
|
|
|
expression { return isBuildSuccess() }
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
// push changes back to remote repository
|
|
|
|
|
authGit 'cesmarvin-github', 'push origin master --tags'
|
|
|
|
|
authGit 'cesmarvin-github', 'push origin --tags'
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-10 21:47:35 +02:00
|
|
|
|
2020-03-11 11:05:54 +01:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Set Next Version') {
|
|
|
|
|
when {
|
|
|
|
|
branch pattern: 'release/*', comparator: 'GLOB'
|
|
|
|
|
expression { return isBuildSuccess() }
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
sh returnStatus: true, script: "git branch -D develop"
|
|
|
|
|
sh "git checkout develop"
|
2021-01-29 12:06:17 +01:00
|
|
|
sh "git -c user.name='CES Marvin' -c user.email='cesmarvin@cloudogu.com' merge master"
|
2020-05-10 21:47:35 +02:00
|
|
|
|
2021-01-14 08:29:36 +01:00
|
|
|
gradle "setVersionToNextSnapshot"
|
2020-05-10 21:47:35 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
sh "git add gradle.properties lerna.json '**.json'"
|
|
|
|
|
commit 'Prepare for next development iteration'
|
|
|
|
|
authGit 'cesmarvin-github', 'push origin develop'
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-10 21:47:35 +02:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
stage('Delete Release Branch') {
|
|
|
|
|
when {
|
|
|
|
|
branch pattern: 'release/*', comparator: 'GLOB'
|
|
|
|
|
expression { return isBuildSuccess() }
|
|
|
|
|
}
|
|
|
|
|
steps {
|
|
|
|
|
authGit 'cesmarvin-github', "push origin :${env.BRANCH_NAME}"
|
2018-09-24 17:13:47 +02:00
|
|
|
}
|
2018-05-31 12:34:34 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
}
|
2021-01-13 15:37:57 +01:00
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
post {
|
|
|
|
|
failure {
|
|
|
|
|
mail to: "scm-team@cloudogu.com",
|
|
|
|
|
subject: "Jenkins Job ${JOB_NAME} - Build #${BUILD_NUMBER} - ${currentBuild.currentResult}!",
|
|
|
|
|
body: "Check console output at ${BUILD_URL} to view the results."
|
|
|
|
|
}
|
|
|
|
|
unstable {
|
|
|
|
|
mail to: "scm-team@cloudogu.com",
|
|
|
|
|
subject: "Jenkins Job ${JOB_NAME} - Build #${BUILD_NUMBER} - ${currentBuild.currentResult}!",
|
|
|
|
|
body: "Check console output at ${BUILD_URL} to view the results."
|
|
|
|
|
}
|
|
|
|
|
fixed {
|
|
|
|
|
mail to: "scm-team@cloudogu.com",
|
|
|
|
|
subject: "Jenkins Job ${JOB_NAME} - Is back to normal with Build #${BUILD_NUMBER}",
|
|
|
|
|
body: "Check console output at ${BUILD_URL} to view the results."
|
|
|
|
|
}
|
2018-09-12 18:01:00 +02:00
|
|
|
}
|
2018-05-31 12:34:34 +02:00
|
|
|
}
|
2018-07-11 18:23:49 +02:00
|
|
|
|
2021-01-14 08:29:36 +01:00
|
|
|
void gradle(String command) {
|
|
|
|
|
// setting user home system property, should fix user prefs (?/.java/.prefs ...)
|
|
|
|
|
sh "./gradlew -Duser.home=${env.WORKSPACE} ${command}"
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
String getReleaseVersion() {
|
|
|
|
|
return env.BRANCH_NAME.substring("release/".length());
|
2018-07-12 11:15:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
void commit(String message) {
|
|
|
|
|
sh "git -c user.name='CES Marvin' -c user.email='cesmarvin@cloudogu.com' commit -m '${message}'"
|
2020-03-11 11:05:54 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
void tag(String version) {
|
|
|
|
|
String message = "Release version ${version}"
|
|
|
|
|
sh "git -c user.name='CES Marvin' -c user.email='cesmarvin@cloudogu.com' tag -m '${message}' ${version}"
|
2020-03-11 11:05:54 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 13:30:44 +01:00
|
|
|
void isBuildSuccess() {
|
|
|
|
|
return currentBuild.result == null || currentBuild.result == 'SUCCESS'
|
2018-09-25 09:22:25 +02:00
|
|
|
}
|
|
|
|
|
|
2021-05-11 14:09:09 +02:00
|
|
|
void withCheckEnvironment(Closure<Void> closure) {
|
2021-09-08 09:59:51 +02:00
|
|
|
// surround call withChromaticEnvironment to enable chromatic analyzation
|
|
|
|
|
closure.call()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void withChromaticEnvironment(Closure<Void> closure) {
|
2021-05-11 14:09:09 +02:00
|
|
|
// apply chromatic environment only if we are on a pr build or on the develop branch
|
|
|
|
|
if (env.CHANGE_ID || env.BRANCH_NAME == 'develop') {
|
|
|
|
|
withCredentials([
|
|
|
|
|
usernamePassword(credentialsId: 'chromatic-scm-manager', usernameVariable: 'CHROMATIC_USERANAME', passwordVariable: 'CHROMATIC_PROJECT_TOKEN'),
|
|
|
|
|
]) {
|
|
|
|
|
closure.call()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
closure.call()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 15:08:10 +01:00
|
|
|
void withPublishEnivronment(Closure<Void> closure) {
|
2020-05-26 09:47:38 +02:00
|
|
|
withCredentials([
|
2021-01-14 15:08:10 +01:00
|
|
|
usernamePassword(credentialsId: 'maven.scm-manager.org', usernameVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerUsername', passwordVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerPassword'),
|
|
|
|
|
usernamePassword(credentialsId: 'hub.docker.com-cesmarvin', usernameVariable: 'ORG_GRADLE_PROJECT_dockerUsername', passwordVariable: 'ORG_GRADLE_PROJECT_dockerPassword'),
|
2021-01-15 07:38:06 +01:00
|
|
|
usernamePassword(credentialsId: 'cesmarvin-github', usernameVariable: 'ORG_GRADLE_PROJECT_gitHubUsername', passwordVariable: 'ORG_GRADLE_PROJECT_gitHubApiToken'),
|
2021-01-14 15:08:10 +01:00
|
|
|
string(credentialsId: 'cesmarvin_npm_token', variable: 'ORG_GRADLE_PROJECT_npmToken'),
|
2021-01-15 09:16:22 +01:00
|
|
|
file(credentialsId: 'oss-gpg-secring', variable: 'GPG_KEY_RING'),
|
|
|
|
|
usernamePassword(credentialsId: 'oss-keyid-and-passphrase', usernameVariable: 'GPG_KEY_ID', passwordVariable: 'GPG_KEY_PASSWORD')
|
2020-05-26 09:47:38 +02:00
|
|
|
]) {
|
2021-01-14 15:08:10 +01:00
|
|
|
withEnv(["ORG_GRADLE_PROJECT_npmEmail=cesmarvin@cloudogu.com"]) {
|
2021-01-13 13:30:44 +01:00
|
|
|
closure.call()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void authGit(String credentials, String command) {
|
|
|
|
|
withCredentials([
|
|
|
|
|
usernamePassword(credentialsId: credentials, usernameVariable: 'AUTH_USR', passwordVariable: 'AUTH_PSW')
|
|
|
|
|
]) {
|
|
|
|
|
sh "git -c credential.helper=\"!f() { echo username='\$AUTH_USR'; echo password='\$AUTH_PSW'; }; f\" ${command}"
|
2020-05-26 09:47:38 +02:00
|
|
|
}
|
|
|
|
|
}
|