mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
Migrate SCM-Manager from GitHub to Cloudogu EcoSystem
Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
69
Jenkinsfile
vendored
69
Jenkinsfile
vendored
@@ -41,8 +41,8 @@ pipeline {
|
||||
script {
|
||||
if (isReleaseBuild()) {
|
||||
// checkout, reset and merge
|
||||
sh 'git checkout master'
|
||||
sh 'git reset --hard origin/master'
|
||||
sh 'git checkout main'
|
||||
sh 'git reset --hard origin/main'
|
||||
sh "git merge --ff-only ${env.BRANCH_NAME}"
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('SonarQube') {
|
||||
stage('SonarQube') {
|
||||
steps {
|
||||
sh 'git config --replace-all "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*"'
|
||||
sh 'git fetch origin develop'
|
||||
@@ -116,7 +116,7 @@ pipeline {
|
||||
expression { return isBuildSuccess() }
|
||||
}
|
||||
steps {
|
||||
withPublishEnivronment {
|
||||
withPublishEnvironment {
|
||||
gradle "-PenablePackaging publish"
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ pipeline {
|
||||
script {
|
||||
def imageVersion = readFile 'scm-packaging/docker/build/docker.tag'
|
||||
|
||||
build job: 'scm-manager/next-scm.cloudogu.com', propagate: false, wait: false, parameters: [
|
||||
build job: 'scm-manager/scm-manager/next-scm.cloudogu.com/master', propagate: false, wait: false, parameters: [
|
||||
string(name: 'imageTag', value: imageVersion)
|
||||
]
|
||||
}
|
||||
@@ -165,11 +165,11 @@ pipeline {
|
||||
script {
|
||||
// push changes back to remote repository
|
||||
if (isReleaseBuild()) {
|
||||
authGit 'cesmarvin-github', 'push origin master --tags'
|
||||
authGit 'cesmarvin', 'push origin main--tags'
|
||||
} else {
|
||||
authGit 'cesmarvin-github', "push origin ${env.BRANCH_NAME} --tags"
|
||||
authGit 'cesmarvin', "push origin ${env.BRANCH_NAME} --tags"
|
||||
}
|
||||
authGit 'cesmarvin-github', 'push origin --tags'
|
||||
authGit 'cesmarvin', 'push origin --tags'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,13 +182,13 @@ pipeline {
|
||||
steps {
|
||||
sh returnStatus: true, script: "git branch -D develop"
|
||||
sh "git checkout develop"
|
||||
sh "git -c user.name='CES Marvin' -c user.email='cesmarvin@cloudogu.com' merge master"
|
||||
sh "git -c user.name='CES Marvin' -c user.email='cesmarvin@cloudogu.com' merge main"
|
||||
|
||||
gradle "setVersionToNextSnapshot"
|
||||
|
||||
sh "git add gradle.properties '**.json'"
|
||||
commit 'Prepare for next development iteration'
|
||||
authGit 'cesmarvin-github', 'push origin develop'
|
||||
authGit 'cesmarvin', 'push origin develop'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,22 @@ pipeline {
|
||||
expression { return isBuildSuccess() }
|
||||
}
|
||||
steps {
|
||||
authGit 'cesmarvin-github', "push origin :${env.BRANCH_NAME}"
|
||||
authGit 'cesmarvin', "push origin :${env.BRANCH_NAME}"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push to GitHub') {
|
||||
when {
|
||||
anyOf {
|
||||
branch pattern: 'develop', comparator: 'GLOB'
|
||||
branch pattern: 'main', comparator: 'GLOB'
|
||||
branch pattern: 'support/*', comparator: 'GLOB'
|
||||
}
|
||||
expression { return isBuildSuccess() }
|
||||
}
|
||||
steps {
|
||||
authGit 'cesmarvin', "push https://github.com/scm-manager/scm-manager HEAD:${env.BRANCH_NAME}"
|
||||
authGit 'cesmarvin', "push --tags https://github.com/scm-manager/scm-manager"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,8 +226,8 @@ pipeline {
|
||||
mail to: "scm-team@cloudogu.com",
|
||||
subject: "Jenkins Job ${JOB_NAME} - Merge Hotfix Release #${env.BRANCH_NAME}!",
|
||||
body: """Please,
|
||||
- merge the hotfix release branch ${env.BRANCH_NAME} into master (keep versions of master, merge changelog to keep both versions),
|
||||
- merge master into develop (the changelog should have no conflicts),
|
||||
- merge the hotfix release branch ${env.BRANCH_NAME} into main (keep versions of main, merge changelog to keep both versions),
|
||||
- merge main into develop (the changelog should have no conflicts),
|
||||
- if needed, increase version."""
|
||||
}
|
||||
}
|
||||
@@ -268,33 +283,19 @@ boolean isBuildSuccess() {
|
||||
}
|
||||
|
||||
void withCheckEnvironment(Closure<Void> closure) {
|
||||
// surround call withChromaticEnvironment to enable chromatic analyzation
|
||||
closure.call()
|
||||
}
|
||||
|
||||
void withChromaticEnvironment(Closure<Void> closure) {
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
|
||||
void withPublishEnivronment(Closure<Void> closure) {
|
||||
void withPublishEnvironment(Closure<Void> closure) {
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'maven.scm-manager.org', usernameVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerUsername', passwordVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerPassword'),
|
||||
usernamePassword(credentialsId: 'cesmarvin-github', usernameVariable: 'ORG_GRADLE_PROJECT_gitHubUsername', passwordVariable: 'ORG_GRADLE_PROJECT_gitHubApiToken'),
|
||||
string(credentialsId: 'cesmarvin_npm_token', variable: 'ORG_GRADLE_PROJECT_npmToken'),
|
||||
file(credentialsId: 'oss-gpg-secring', variable: 'GPG_KEY_RING'),
|
||||
usernamePassword(credentialsId: 'oss-keyid-and-passphrase', usernameVariable: 'GPG_KEY_ID', passwordVariable: 'GPG_KEY_PASSWORD')
|
||||
usernamePassword(credentialsId: 'packages-scm-manager-org', usernameVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerUsername', passwordVariable: 'ORG_GRADLE_PROJECT_packagesScmManagerPassword'),
|
||||
string(credentialsId: 'SCM-Manager_ApiKey', variable: 'ORG_GRADLE_PROJECT_ecosystemApiToken'),
|
||||
string(credentialsId: 'npm-token-scm-manager', variable: 'ORG_GRADLE_PROJECT_npmToken'),
|
||||
file(credentialsId: 'gpg_packages-scm-manager-org', variable: 'GPG_KEY_RING'),
|
||||
usernamePassword(credentialsId: 'gpg_packages-scm-manager-org-credentials', usernameVariable: 'GPG_KEY_ID', passwordVariable: 'GPG_KEY_PASSWORD')
|
||||
]) {
|
||||
withEnv(["ORG_GRADLE_PROJECT_npmEmail=cesmarvin@cloudogu.com"]) {
|
||||
docker.withRegistry('', 'hub.docker.com-cesmarvin') {
|
||||
docker.withRegistry('', 'cesmarvin-dockerhub-access-token') {
|
||||
closure.call()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class PackagingPlugin implements Plugin<Project> {
|
||||
project.ext.ReleaseYaml = ReleaseYamlTask
|
||||
project.ext.HttpUploadTask = HttpUploadTask
|
||||
project.ext.GitHubUploadTask = GitHubUploadTask
|
||||
project.ext.ScmManagerUploadTask = ScmManagerUploadTask
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.cloudogu.scm
|
||||
|
||||
import com.google.common.base.Strings
|
||||
import groovy.json.JsonOutput
|
||||
import org.eclipse.jetty.client.HttpClient
|
||||
import org.eclipse.jetty.client.api.Request
|
||||
import org.eclipse.jetty.client.util.StringContentProvider
|
||||
import org.eclipse.jetty.http.HttpMethod
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.Optional
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
class ScmManagerUploadTask extends UploadTask {
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
String apiToken
|
||||
|
||||
@Input
|
||||
String server
|
||||
|
||||
@Input
|
||||
String namespace
|
||||
|
||||
@Input
|
||||
String repo
|
||||
|
||||
@Input
|
||||
String path
|
||||
|
||||
@Input
|
||||
String branch = "master"
|
||||
|
||||
@Input
|
||||
String message
|
||||
|
||||
@Override
|
||||
Request createRequest(HttpClient client) {
|
||||
String[] pathComponents = path.split("/")
|
||||
String filename = pathComponents[pathComponents.length - 1]
|
||||
String directory = path.substring(0, path.length() - filename.length() - 1)
|
||||
Request request = client.newRequest("${server}/api/v2/edit/${namespace}/${repo}/create/${directory}")
|
||||
request.method(HttpMethod.POST)
|
||||
request.header("Accept", "application/json")
|
||||
request.header("Content-Type", "application/json")
|
||||
if (!Strings.isNullOrEmpty(apiToken)) {
|
||||
request.header("Authorization","Bearer ${apiToken}")
|
||||
}
|
||||
|
||||
def body = [
|
||||
commitMessage: message,
|
||||
branch: branch,
|
||||
fileName: filename,
|
||||
fileContent: artifact.text
|
||||
]
|
||||
request.content(new StringContentProvider(JsonOutput.toJson(body), StandardCharsets.UTF_8))
|
||||
return request
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import com.cloudogu.scm.GitHubUploadTask
|
||||
import com.cloudogu.scm.ScmManagerUploadTask
|
||||
|
||||
plugins {
|
||||
id 'org.scm-manager.packaging'
|
||||
@@ -48,19 +48,16 @@ task distribution(type: ReleaseYaml) {
|
||||
configuration = configurations.packageYaml
|
||||
}
|
||||
|
||||
task publish(type: GitHubUploadTask) {
|
||||
owner = "scm-manager"
|
||||
task publish(type: ScmManagerUploadTask) {
|
||||
server = "https://ecosystem.cloudogu.com/scm"
|
||||
namespace = "scm-manager"
|
||||
repo = "website"
|
||||
path = "content/releases/${project.version.replace('.', '-')}.yml"
|
||||
branch = "master"
|
||||
message = "Add release descriptor for ${project.version}"
|
||||
author {
|
||||
name = "CES Marvin"
|
||||
email = "cesmarvin@cloudogu.com"
|
||||
}
|
||||
artifact = file('build/libs/release.yml')
|
||||
if (project.hasProperty("gitHubApiToken")) {
|
||||
apiToken = project.property("gitHubApiToken")
|
||||
if (project.hasProperty("ecosystemApiToken")) {
|
||||
apiToken = project.property("ecosystemApiToken")
|
||||
}
|
||||
skip = isSnapshot
|
||||
dependsOn 'distribution'
|
||||
|
||||
Reference in New Issue
Block a user