Skip to content

Commit

Permalink
feat: Implement cache in maven pipelines (#74)
Browse files Browse the repository at this point in the history
before:

   init-values -> compile -> test -> sonar -> build -> push

after:

     get-cache -> compile -> test -> sonar -> build -> save-cache
              /                                       \
init-values -                                          -> push

Change-Id: Ie8b1bb33a17d26f33e7dd16482747d7c79f55e8b
  • Loading branch information
Mykola Serdiuk committed Dec 1, 2023
1 parent 244e6b3 commit fae164c
Show file tree
Hide file tree
Showing 22 changed files with 345 additions and 445 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
{{- define "java-maven-build-common" -}}
- name: compile
taskRef:
kind: Task
name: maven
runAfter:
- get-cache
- security
params:
- name: MAVEN_IMAGE
value: $(params.image)
- name: GOALS
value:
- -B
- '-Dartifactory.baseUrl=${NEXUS_HOST_URL}'
- '-Dartifactory.releasePath=edp-maven-releases'
- '-Dartifactory.snapshotsPath=edp-maven-snapshots'
- '-Dartifactory.groupPath=edp-maven-group'
- compile
workspaces:
- name: source
workspace: shared-workspace

- name: test
taskRef:
kind: Task
Expand All @@ -22,7 +44,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: sonar
taskRef:
Expand All @@ -48,7 +69,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: build
taskRef:
Expand All @@ -72,7 +92,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: get-nexus-repository-url
taskRef:
Expand Down Expand Up @@ -109,7 +128,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source
{{- end -}}

{{- define "java-maven-review-common" -}}
Expand All @@ -118,7 +136,7 @@
kind: Task
name: maven
runAfter:
- init-values
- get-cache
params:
- name: MAVEN_IMAGE
value: $(params.image)
Expand All @@ -133,7 +151,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: test
taskRef:
Expand All @@ -158,7 +175,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source

# The fetch-target-branch Task will fetch the target branch during the code-review pipeline
# because the fetch-repository Task fetches only user changes.
Expand Down Expand Up @@ -230,7 +246,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: build
taskRef:
Expand All @@ -254,7 +269,6 @@
workspaces:
- name: source
workspace: shared-workspace
subPath: source
{{- end -}}

{{- define "java-maven-get-module" -}}
Expand Down Expand Up @@ -296,6 +310,7 @@
runAfter:
- get-maven-module
- push
- build
params:
- name: codebase-name
value: "$(params.CODEBASE_NAME)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ spec:
workspace: shared-workspace
subPath: source

{{- include "get-cache" $ | nindent 4 }}

- name: update-build-number
taskRef:
kind: Task
name: update-build-number-maven-default
runAfter:
- get-version
- get-cache
params:
- name: VERSION
value: $(tasks.get-version.results.VERSION)
Expand All @@ -101,32 +104,12 @@ spec:

{{ include "security-edp" . | nindent 4 }}

- name: compile
taskRef:
kind: Task
name: maven
runAfter:
- security
params:
- name: MAVEN_IMAGE
value: $(params.image)
- name: GOALS
value:
- -B
- '-Dartifactory.baseUrl=${NEXUS_HOST_URL}'
- '-Dartifactory.releasePath=edp-maven-releases'
- '-Dartifactory.snapshotsPath=edp-maven-snapshots'
- '-Dartifactory.groupPath=edp-maven-group'
- compile
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{- include "java-maven-build-common" . | nindent 4 }}

{{- include "build-pipeline-java-maven-image-build-push-common" $ | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

{{ include "build-pipeline-end" . | nindent 4 }}

{{ include "finally-block-default" . | nindent 2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ spec:
- name: CODEBASEBRANCH_NAME
value: $(params.CODEBASEBRANCH_NAME)

{{- include "get-cache" $ | nindent 4 }}

- name: update-build-number
taskRef:
kind: Task
name: update-build-number-maven
runAfter:
- get-version
- get-cache
params:
- name: IS_RELEASE_BRANCH
value: $(tasks.get-version.results.IS_RELEASE_BRANCH)
Expand All @@ -99,32 +102,12 @@ spec:

{{ include "security-edp" . | nindent 4 }}

- name: compile
taskRef:
kind: Task
name: maven
runAfter:
- security
params:
- name: MAVEN_IMAGE
value: $(params.image)
- name: GOALS
value:
- -B
- '-Dartifactory.baseUrl=${NEXUS_HOST_URL}'
- '-Dartifactory.releasePath=edp-maven-releases'
- '-Dartifactory.snapshotsPath=edp-maven-snapshots'
- '-Dartifactory.groupPath=edp-maven-group'
- compile
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{- include "java-maven-build-common" . | nindent 4 }}

{{- include "build-pipeline-java-maven-image-build-push-common" $ | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

{{ include "build-pipeline-end" . | nindent 4 }}

{{ include "finally-block-edp" . | nindent 2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ spec:
workspace: shared-workspace
subPath: source

{{- include "get-cache" $ | nindent 4 }}

- name: update-build-number
taskRef:
kind: Task
name: update-build-number-maven-default
runAfter:
- get-version
- get-cache
params:
- name: VERSION
value: $(tasks.get-version.results.VERSION)
Expand All @@ -99,30 +102,10 @@ spec:

{{ include "security-edp" . | nindent 4 }}

- name: compile
taskRef:
kind: Task
name: maven
runAfter:
- security
params:
- name: MAVEN_IMAGE
value: $(params.image)
- name: GOALS
value:
- -B
- '-Dartifactory.baseUrl=${NEXUS_HOST_URL}'
- '-Dartifactory.releasePath=edp-maven-releases'
- '-Dartifactory.snapshotsPath=edp-maven-snapshots'
- '-Dartifactory.groupPath=edp-maven-group'
- compile
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{- include "java-maven-build-common" . | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

{{ include "build-pipeline-lib-end" . | nindent 4 }}

{{ include "finally-block-default" . | nindent 2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ spec:
- name: CODEBASEBRANCH_NAME
value: $(params.CODEBASEBRANCH_NAME)

{{- include "get-cache" $ | nindent 4 }}

- name: update-build-number
taskRef:
kind: Task
name: update-build-number-maven
runAfter:
- get-version
- get-cache
params:
- name: IS_RELEASE_BRANCH
value: $(tasks.get-version.results.IS_RELEASE_BRANCH)
Expand All @@ -97,30 +100,10 @@ spec:

{{ include "security-edp" . | nindent 4 }}

- name: compile
taskRef:
kind: Task
name: maven
runAfter:
- security
params:
- name: MAVEN_IMAGE
value: $(params.image)
- name: GOALS
value:
- -B
- '-Dartifactory.baseUrl=${NEXUS_HOST_URL}'
- '-Dartifactory.releasePath=edp-maven-releases'
- '-Dartifactory.snapshotsPath=edp-maven-snapshots'
- '-Dartifactory.groupPath=edp-maven-group'
- compile
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{- include "java-maven-build-common" . | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

{{ include "build-pipeline-lib-end" . | nindent 4 }}

{{ include "finally-block-edp" . | nindent 2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ spec:

{{- include "gerrit-review-start" $ | nindent 4 }}

{{- include "get-cache" $ | nindent 4 }}

{{- include "java-maven-review-common" . | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

{{ include "gerrit-review-vote" $ | nindent 2 }}

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ spec:

{{- include "helm-docs" $ | nindent 4 }}

{{- include "get-cache" $ | nindent 4 }}

{{- include "java-maven-get-module" . | nindent 4 }}

{{- include "java-maven-review-common" . | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

- name: dockerfile-lint
taskRef:
kind: Task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ spec:
workspace: shared-workspace
subPath: source

{{- include "get-cache" $ | nindent 4 }}

- name: update-build-number
taskRef:
kind: Task
name: update-build-number-maven-default
runAfter:
- get-version
- get-cache
params:
- name: VERSION
value: $(tasks.get-version.results.VERSION)
Expand All @@ -95,32 +98,12 @@ spec:

{{ include "security-edp" . | nindent 4 }}

- name: compile
taskRef:
kind: Task
name: maven
runAfter:
- security
params:
- name: MAVEN_IMAGE
value: $(params.image)
- name: GOALS
value:
- -B
- '-Dartifactory.baseUrl=${NEXUS_HOST_URL}'
- '-Dartifactory.releasePath=edp-maven-releases'
- '-Dartifactory.snapshotsPath=edp-maven-snapshots'
- '-Dartifactory.groupPath=edp-maven-group'
- compile
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{- include "java-maven-build-common" . | nindent 4 }}

{{- include "build-pipeline-java-maven-image-build-push-common" $ | nindent 4 }}

{{- include "save-cache" $ | nindent 4 }}

{{ include "build-pipeline-end" . | nindent 4 }}

{{ include "finally-block-default" . | nindent 2 }}
Expand Down
Loading

0 comments on commit fae164c

Please sign in to comment.