Skip to content

Commit 0274612

Browse files
authored
Merge pull request #234 from cloudogu/feature/custom-maven-and-registry-support
adding custom maven image and registry support
2 parents d456b92 + ba8acf5 commit 0274612

File tree

10 files changed

+69
-5
lines changed

10 files changed

+69
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ Note that you can get a free CES demo instance set up with a Kubernetes Cluster
450450
--registry-password="$( cat account.json | sed 's/"/\\"/g' )"
451451
```
452452

453-
##### Override default images
453+
##### Override default images
454454

455455
###### gitops-build-lib
456456

@@ -486,6 +486,7 @@ Images used by various tools and exercises can be configured using the following
486486
* `--external-secrets-webhook-image someRegistry/someImage:1.0.0`
487487
* `--vault-image someRegistry/someImage:1.0.0`
488488
* `--nginx-image someRegistry/someImage:1.0.0`
489+
* `--maven-image someRegistry/someImage:1.0.0`
489490

490491
Note that specifying a tag is mandatory.
491492

applications/argocd/petclinic/helm/Jenkinsfile.ftl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,17 @@ properties([
3838

3939
node {
4040

41-
mvn = cesBuildLib.MavenWrapper.new(this)
4241
</#noparse>
42+
<#if images.maven?has_content>
43+
<#if registry.twoRegistries>
44+
mvn = cesBuildLib.MavenInDocker.new(this, '${images.maven}', dockerRegistryProxyCredentials)
45+
<#else>
46+
mvn = cesBuildLib.MavenInDocker.new(this, '${images.maven}')
47+
</#if>
48+
<#else>
49+
mvn = cesBuildLib.MavenWrapper.new(this)
50+
</#if>
51+
4352
<#if jenkins.mavenCentralMirror?has_content>
4453
mvn.useMirrors([name: 'maven-central-mirror', mirrorOf: 'central', url: env.${namePrefixForEnvVars}MAVEN_CENTRAL_MIRROR])
4554
</#if>

applications/argocd/petclinic/plain-k8s/Jenkinsfile.ftl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@ properties([
2929

3030
node {
3131

32-
mvn = cesBuildLib.MavenWrapper.new(this)
3332
</#noparse>
33+
34+
<#if images.maven?has_content>
35+
<#if registry.twoRegistries>
36+
mvn = cesBuildLib.MavenInDocker.new(this, '${images.maven}', dockerRegistryProxyCredentials)
37+
<#else>
38+
mvn = cesBuildLib.MavenInDocker.new(this, '${images.maven}')
39+
</#if>
40+
<#else>
41+
mvn = cesBuildLib.MavenWrapper.new(this)
42+
</#if>
43+
3444
<#if jenkins.mavenCentralMirror?has_content>
3545
mvn.useMirrors([name: 'maven-central-mirror', mirrorOf: 'central', url: env.${namePrefixForEnvVars}MAVEN_CENTRAL_MIRROR])
3646
</#if>

docs/configuration.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@
444444
"type" : "string",
445445
"description" : "Sets image for kubeval"
446446
},
447+
"maven" : {
448+
"type" : "string",
449+
"description" : "Sets image for maven"
450+
},
447451
"nginx" : {
448452
"type" : "string",
449453
"description" : "Sets image for nginx used in various applications"

src/main/groovy/com/cloudogu/gitops/cli/GitopsPlaygroundCli.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class GitopsPlaygroundCli implements Runnable {
101101
private String helmKubevalImage
102102
@Option(names = ['--yamllint-image'], description = YAMLLINT_IMAGE_DESCRIPTION)
103103
private String yamllintImage
104+
@Option(names = ['--maven-image'], description = MAVEN_IMAGE_DESCRIPTION)
105+
private String mavenImage
104106
@Option(names = ['--grafana-image'], description = GRAFANA_IMAGE_DESCRIPTION)
105107
private String grafanaImage
106108
@Option(names = ['--grafana-sidecar-image'], description = GRAFANA_SIDECAR_IMAGE_DESCRIPTION)
@@ -433,6 +435,7 @@ class GitopsPlaygroundCli implements Runnable {
433435
yamllint : yamllintImage,
434436
nginx : nginxImage,
435437
petclinic : petClinicImage,
438+
maven : mavenImage
436439
],
437440
features : [
438441
argocd : [

src/main/groovy/com/cloudogu/gitops/config/ApplicationConfigurator.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ class ApplicationConfigurator {
132132
helmKubeval: HELM_IMAGE,
133133
yamllint : "cytopia/yamllint:1.25-0.7",
134134
nginx : null,
135-
petclinic : 'eclipse-temurin:11-jre-alpine'
135+
petclinic : 'eclipse-temurin:11-jre-alpine',
136+
maven : null
136137
],
137138
repositories : [
138139
springBootHelmChart: [

src/main/groovy/com/cloudogu/gitops/config/ConfigConstants.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface ConfigConstants {
5353
String KUBEVAL_IMAGE_DESCRIPTION = 'Sets image for kubeval'
5454
String HELMKUBEVAL_IMAGE_DESCRIPTION = 'Sets image for helmkubeval'
5555
String YAMLLINT_IMAGE_DESCRIPTION = 'Sets image for yamllint'
56+
String MAVEN_IMAGE_DESCRIPTION = 'Sets image for maven'
5657
String GRAFANA_IMAGE_DESCRIPTION = 'Sets image for grafana'
5758
String GRAFANA_SIDECAR_IMAGE_DESCRIPTION = 'Sets image for grafana\'s sidecar'
5859
String PROMETHEUS_IMAGE_DESCRIPTION = 'Sets image for prometheus'

src/main/groovy/com/cloudogu/gitops/config/schema/Schema.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ class Schema {
190190
String nginx = ""
191191
@JsonPropertyDescription(PETCLINIC_IMAGE_DESCRIPTION)
192192
String petclinic = ""
193+
@JsonPropertyDescription(MAVEN_IMAGE_DESCRIPTION)
194+
String maven = ""
193195
}
194196

195197
static class RepositoriesSchema {

src/test/groovy/com/cloudogu/gitops/config/ConfigToConfigFileConverterTest.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class ConfigToConfigFileConverterTest {
7676
helmKubeval: 'helmKubeval-value',
7777
yamllint : 'yamllint-value',
7878
nginx: 'nginx-value',
79-
petclinic : 'petclinic-value'
79+
petclinic : 'petclinic-value',
80+
maven : 'maven-value'
8081
],
8182
repositories : [
8283
springBootHelmChart: [
@@ -236,6 +237,7 @@ images:
236237
yamllint: "yamllint-value"
237238
nginx: "nginx-value"
238239
petclinic: "petclinic-value"
240+
maven: "maven-value"
239241
repositories:
240242
springBootHelmChart:
241243
url: "springboot-url"

src/test/groovy/com/cloudogu/gitops/features/argocd/ArgoCDTest.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,35 @@ class ArgoCDTest {
694694
}
695695
}
696696

697+
@Test
698+
void 'use custom maven image'() {
699+
config.images['maven'] = 'maven:latest'
700+
701+
createArgoCD().install()
702+
703+
for (def petclinicRepo : petClinicRepos) {
704+
if (petclinicRepo.scmmRepoTarget.contains('argocd/petclinic-plain')) {
705+
assertThat(new File(petclinicRepo.absoluteLocalRepoTmpDir, 'Jenkinsfile').text).contains('mvn = cesBuildLib.MavenInDocker.new(this, \'maven:latest\')')
706+
}
707+
}
708+
}
709+
710+
@Test
711+
void 'use maven with proxy registry and credentials'() {
712+
config.images['maven'] = 'latest'
713+
config.registry['twoRegistries'] = true
714+
715+
createArgoCD().install()
716+
717+
for (def petclinicRepo : petClinicRepos) {
718+
if (petclinicRepo.scmmRepoTarget.contains('argocd/petclinic-plain')) {
719+
assertThat(new File(petclinicRepo.absoluteLocalRepoTmpDir, 'Jenkinsfile').text).contains('mvn = cesBuildLib.MavenInDocker.new(this, \'latest\', dockerRegistryProxyCredentials)')
720+
}
721+
}
722+
723+
}
724+
725+
697726
@Test
698727
void 'Sets pod resource limits and requests'() {
699728
config.application['podResources'] = true
@@ -735,6 +764,8 @@ class ArgoCDTest {
735764
assertPetClinicRepos('NodePort', 'LoadBalancer', '')
736765
}
737766

767+
768+
738769
private static Map parseBuildImagesMapFromString(String text) {
739770
def startIndex = text.indexOf('buildImages')
740771
if (startIndex != -1) {

0 commit comments

Comments
 (0)