Skip to content

Commit

Permalink
#4 add CRD-Release to Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kahoona77 committed Sep 27, 2023
1 parent ec22e94 commit 720743d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- [#4] Add CRD-Release to Jenkinsfile

## [v0.1.0] - 2023-09-05

Expand Down
16 changes: 12 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ void stageStaticAnalysisSonarQube() {

void stageAutomaticRelease(Makefile makefile) {
if (gitflow.isReleaseBranch()) {
String releaseVersion = git.getSimpleBranchName()
String dockerReleaseVersion = releaseVersion.split("v")[1]
String controllerVersion = makefile.getVersion()
String releaseVersion = "v${controllerVersion}".toString()

stage('Build & Push Image') {
withCredentials([usernamePassword(credentialsId: 'cesmarvin',
Expand All @@ -200,10 +199,10 @@ void stageAutomaticRelease(Makefile makefile) {
"login ${CES_MARVIN_USERNAME}\n" +
"password ${CES_MARVIN_PASSWORD}\" >> ~/.netrc"
}
def dockerImage = docker.build("cloudogu/${repositoryName}:${dockerReleaseVersion}")
def dockerImage = docker.build("cloudogu/${repositoryName}:${controllerVersion}")
sh "rm ~/.netrc"
docker.withRegistry('https://registry.hub.docker.com/', 'dockerHubCredentials') {
dockerImage.push("${dockerReleaseVersion}")
dockerImage.push("${controllerVersion}")
}
}

Expand Down Expand Up @@ -238,12 +237,21 @@ void stageAutomaticRelease(Makefile makefile) {
.mountJenkinsUser()
.inside("--volume ${WORKSPACE}:/go/src/${project} -w /go/src/${project}")
{
// Package & Push operator-chart
make 'k8s-helm-package-release'

withCredentials([usernamePassword(credentialsId: 'harborhelmchartpush', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) {
sh ".bin/helm registry login ${registry} --username '${HARBOR_USERNAME}' --password '${HARBOR_PASSWORD}'"
sh ".bin/helm push target/helm/${repositoryName}-${controllerVersion}.tgz oci://${registry}/${registry_namespace}/"
}

// Package & Push crd-chart
make 'crd-helm-package'

withCredentials([usernamePassword(credentialsId: 'harborhelmchartpush', usernameVariable: 'HARBOR_USERNAME', passwordVariable: 'HARBOR_PASSWORD')]) {
sh ".bin/helm registry login ${registry} --username '${HARBOR_USERNAME}' --password '${HARBOR_PASSWORD}'"
sh ".bin/helm push target/helm-crd/${repositoryName}-crd-${controllerVersion}.tgz oci://${registry}/${registry_namespace}/"
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions k8s/helm-crd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: artifact-crd-replaceme
description: A Helm chart for the Backup-CRDs

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.0-replaceme

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.0-replaceme"
5 changes: 5 additions & 0 deletions k8s/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ version: 0.0.0-replaceme
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.0-replaceme"

annotations:
# Dependency for the Dogu-CRD.
# Allow all versions up to next major version to avoid breaking changes
"k8s.cloudogu.com/ces-dependency/k8s-backup-operator-crd": "0.x"

0 comments on commit 720743d

Please sign in to comment.