Skip to content

Commit

Permalink
feat: Implement cache in gradle pipelines (#74)
Browse files Browse the repository at this point in the history
Change-Id: I5ae92e9d711815d3dbbde113a894a5fd338061f7
  • Loading branch information
Mykola Serdiuk committed Dec 6, 2023
1 parent c2aeacc commit a8f0cbb
Show file tree
Hide file tree
Showing 21 changed files with 358 additions and 578 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
{{- define "java-gradle-build-common" -}}
- name: test
- name: build
taskRef:
kind: Task
name: gradle
name: edp-gradle
runAfter:
- compile
- get-cache
- update-build-number
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
test \
jacocoTestReport
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: sonar
taskRef:
kind: Task
name: gradle
runAfter:
- test
- build
params:
- name: BASE_IMAGE
value: $(params.sonar_image)
Expand All @@ -40,24 +35,6 @@
workspace: shared-workspace
subPath: source

- name: build
taskRef:
kind: Task
name: gradle
runAfter:
- sonar
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
build -x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: get-nexus-repository-url
taskRef:
kind: Task
Expand All @@ -75,7 +52,7 @@
kind: Task
name: gradle
runAfter:
- build
- sonar
- get-nexus-repository-url
params:
- name: BASE_IMAGE
Expand All @@ -92,44 +69,18 @@
{{- end -}}

{{- define "java-gradle-review-common" -}}
- name: compile
taskRef:
kind: Task
name: gradle
runAfter:
- init-values
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
clean \
compileJava \
-x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

- name: test
- name: build
taskRef:
kind: Task
name: gradle
name: edp-gradle
runAfter:
- compile
- get-cache
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
test \
jacocoTestReport
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 All @@ -138,7 +89,7 @@
kind: Task
name: git-cli
runAfter:
- test
- build
params:
- name: GIT_USER_EMAIL
value: [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ spec:
workspace: shared-workspace
subPath: source

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

- name: update-build-number
taskRef:
kind: Task
Expand All @@ -99,30 +101,12 @@ spec:

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

- name: compile
taskRef:
kind: Task
name: gradle
runAfter:
- security
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
clean \
compileJava \
-x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

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

{{- include "build-pipeline-java-gradle-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,6 +73,8 @@ spec:
- name: CODEBASEBRANCH_NAME
value: $(params.CODEBASEBRANCH_NAME)

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

- name: update-build-number
taskRef:
kind: Task
Expand All @@ -97,30 +99,12 @@ spec:

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

- name: compile
taskRef:
kind: Task
name: gradle
runAfter:
- security
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
clean \
compileJava \
-x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

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

{{- include "build-pipeline-java-gradle-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,6 +79,8 @@ spec:
workspace: shared-workspace
subPath: source

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

- name: update-build-number
taskRef:
kind: Task
Expand All @@ -99,28 +101,10 @@ spec:

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

- name: compile
taskRef:
kind: Task
name: gradle
runAfter:
- security
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
clean \
compileJava \
-x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{ include "java-gradle-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,6 +73,8 @@ spec:
- name: CODEBASEBRANCH_NAME
value: $(params.CODEBASEBRANCH_NAME)

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

- name: update-build-number
taskRef:
kind: Task
Expand All @@ -97,28 +99,10 @@ spec:

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

- name: compile
taskRef:
kind: Task
name: gradle
runAfter:
- security
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
clean \
compileJava \
-x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

{{ include "java-gradle-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-gradle-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,25 +59,9 @@ spec:

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

{{ include "java-gradle-review-common" . | nindent 4 }}
{{- include "get-cache" $ | nindent 4 }}

- name: build
taskRef:
kind: Task
name: gradle
runAfter:
- sonar
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
build -x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source
{{ include "java-gradle-review-common" . | nindent 4 }}

- name: dockerfile-lint
taskRef:
Expand Down Expand Up @@ -108,6 +92,8 @@ spec:
workspace: shared-workspace
subPath: source

{{- 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 @@ -75,6 +75,8 @@ spec:
workspace: shared-workspace
subPath: source

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

- name: update-build-number
taskRef:
kind: Task
Expand All @@ -93,30 +95,12 @@ spec:

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

- name: compile
taskRef:
kind: Task
name: gradle
runAfter:
- security
params:
- name: BASE_IMAGE
value: $(params.image)
- name: EXTRA_ARGS
value: |
-PnexusMavenRepositoryUrl=${NEXUS_HOST_URL}/repository/edp-maven-group \
clean \
compileJava \
-x test
workspaces:
- name: source
workspace: shared-workspace
subPath: source

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

{{- include "build-pipeline-java-gradle-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 a8f0cbb

Please sign in to comment.