Skip to content

Commit

Permalink
feat: added Maven java 17 pack (#914)
Browse files Browse the repository at this point in the history
* fix: removed deprecated java options

* Replace mvn deploy with mvn install

* Update release.yaml

* Update release.yaml

* chore(deps): upgrade Mentor-Medier/jx3-pipeline-catalog to version 3.2.182

from: https://github.com/Mentor-Medier/mentordigital-dev-jx-cluster.git

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Java 11 update task link to Mentor-medier from jenkins-x

* chore(deps): upgrade Mentor-Medier/jx3-pipeline-catalog to version 3.2.182

from: https://github.com/Mentor-Medier/mentordigital-dev-jx-cluster.git

* Update release.yaml

* Update release.yaml

* chore: use Mentor-Medier catalog

* chore(deps): upgrade Mentor-Medier/jx3-pipeline-catalog to version 3.2.188

from: https://github.com/Mentor-Medier/mentordigital-dev-jx-cluster.git

* chore(deps): upgrade Mentor-Medier/jx3-pipeline-catalog to version 3.2.188

from: https://github.com/Mentor-Medier/mentordigital-dev-jx-cluster.git

* Adding option to use maven batch mode

* Update release.yaml

* Update release.yaml

setting Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn in MAVEN_OPTS to disable logging downloaded libraries

* Update pullrequest.yaml

* chore(deps): upgrade Mentor-Medier/jx3-pipeline-catalog to version 3.2.196

from: https://github.com/Mentor-Medier/mentordigital-dev-jx-cluster.git

* chore(deps): upgrade Mentor-Medier/jx3-pipeline-catalog to version 3.2.196

from: https://github.com/Mentor-Medier/mentordigital-dev-jx-cluster.git

* added mvn-install step to maven-java-16

* feat: added maven-java17 build pack

* fix: merge not resolved

* fix: dockerfile for maven 17

* Update pullrequest.yaml

* fix: reference to jenkins-x repos

* fix: reference to jenkins-x repos

* Update pullrequest.yaml

Co-authored-by: Sazal Kanti Kundu <sajol@users.noreply.github.com>
Co-authored-by: jenkins-x-bot <jenkins-x@googlegroups.com>
Co-authored-by: sultan <sultan@cefalo.com>
Co-authored-by: Sajol <sajolkk@gmail.com>
  • Loading branch information
5 people authored Oct 12, 2021
1 parent 007d71b commit 22ec70a
Show file tree
Hide file tree
Showing 26 changed files with 971 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packs/maven-java16/.lighthouse/jenkins-x/pullrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
env:
- name: MAVEN_OPTS
value: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/maven-java14/pullrequest.yaml@versionStream
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/maven-java16/pullrequest.yaml@versionStream
name: ""
resources:
requests:
Expand Down
2 changes: 1 addition & 1 deletion packs/maven-java16/.lighthouse/jenkins-x/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
env:
- name: MAVEN_OPTS
value: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/maven-java14/release.yaml@versionStream
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/maven-java16/release.yaml@versionStream
name: ""
resources:
requests:
Expand Down
50 changes: 50 additions & 0 deletions packs/maven-java17/.lighthouse/jenkins-x/pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
creationTimestamp: null
name: pullrequest
spec:
pipelineSpec:
tasks:
- name: from-build-pack
resources: {}
taskSpec:
metadata: {}
stepTemplate:
env:
- name: MAVEN_OPTS
value: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/maven-java17/pullrequest.yaml@versionStream
name: ""
resources:
requests:
cpu: 400m
memory: 512Mi
volumeMounts:
- mountPath: /root/.m2/
name: maven-settings
workingDir: /workspace/source
steps:
- image: uses:jenkins-x/jx3-pipeline-catalog/tasks/git-clone/git-clone-pr.yaml@versionStream
name: ""
resources: {}
- name: jx-variables
resources: {}
- name: build-set-version
resources: {}
- name: build-mvn-install
resources: {}
- name: check-registry
resources: {}
- name: build-container-build
resources: {}
- name: promote-jx-preview
resources: {}
volumes:
- name: maven-settings
secret:
secretName: jenkins-maven-settings
podTemplate: {}
serviceAccountName: tekton-bot
timeout: 1h0m0s
status: {}
60 changes: 60 additions & 0 deletions packs/maven-java17/.lighthouse/jenkins-x/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
creationTimestamp: null
name: release
spec:
pipelineSpec:
tasks:
- name: from-build-pack
resources: {}
taskSpec:
metadata: {}
stepTemplate:
env:
- name: MAVEN_OPTS
value: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=25 -Dmaven.wagon.http.retryHandler.count=3
image: uses:jenkins-x/jx3-pipeline-catalog/tasks/maven-java17/release.yaml@versionStream
name: ""
resources:
requests:
cpu: 400m
memory: 512Mi
volumeMounts:
- mountPath: /root/.m2/
name: maven-settings
- mountPath: /root/.gnupg
name: release-gpg
workingDir: /workspace/source
steps:
- image: uses:jenkins-x/jx3-pipeline-catalog/tasks/git-clone/git-clone.yaml@versionStream
name: ""
resources: {}
- name: next-version
resources: {}
- name: jx-variables
resources: {}
- name: build-mvn-deploy
resources: {}
- name: check-registry
resources: {}
- name: build-container-build
resources: {}
- name: promote-changelog
resources: {}
- name: promote-helm-release
resources: {}
- name: promote-jx-promote
resources: {}
volumes:
- name: maven-settings
secret:
secretName: jenkins-maven-settings
- name: release-gpg
secret:
optional: true
secretName: jenkins-release-gpg
podTemplate: {}
serviceAccountName: tekton-bot
timeout: 12h0m0s
status: {}
16 changes: 16 additions & 0 deletions packs/maven-java17/.lighthouse/jenkins-x/triggers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: config.lighthouse.jenkins-x.io/v1alpha1
kind: TriggerConfig
spec:
presubmits:
- name: pr
context: "pr"
always_run: true
optional: false
source: "pullrequest.yaml"
postsubmits:
- name: release
context: "release"
source: "release.yaml"
branches:
- ^main$
- ^master$
14 changes: 14 additions & 0 deletions packs/maven-java17/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM openjdk:17-jdk-slim
ENV PORT 8080
ENV CLASSPATH /opt/lib
EXPOSE 8080

# copy pom.xml and wildcards to avoid this command failing if there's no target/lib directory
COPY pom.xml target/lib* /opt/lib/

# NOTE we assume there's only 1 jar in the target dir
# but at least this means we don't have to guess the name
# we could do with a better way to know the name - or to always create an app.jar or something
COPY target/*.jar /opt/app.jar
WORKDIR /opt
CMD ["java", "-jar", "app.jar"]
21 changes: 21 additions & 0 deletions packs/maven-java17/charts/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions packs/maven-java17/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: REPLACE_ME_APP_NAME
description: A Helm chart for Kubernetes
apiVersion: v1
version: 0.1.0-SNAPSHOT
icon: https://raw.githubusercontent.com/cdfoundation/artwork/master/jenkinsx/icon/color/jenkinsx-icon-color.png
11 changes: 11 additions & 0 deletions packs/maven-java17/charts/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kpt.dev/v1alpha1
kind: Kptfile
metadata:
name: charts
upstream:
type: git
git:
commit: b52b35506a05e046d54615c3ade97f3aef8bfb08
repo: https://github.com/jenkins-x/jx3-pipeline-catalog
directory: /helm/charts
ref: master
48 changes: 48 additions & 0 deletions packs/maven-java17/charts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
CHART_REPO := http://jenkins-x-chartmuseum:8080
CURRENT=$(pwd)
NAME := REPLACE_ME_APP_NAME
OS := $(shell uname)
RELEASE_VERSION := $(shell cat ../../VERSION)

build: clean
rm -rf requirements.lock
helm dependency build
helm lint

install: clean build
helm install . --name ${NAME}

upgrade: clean build
helm upgrade ${NAME} .

delete:
helm delete --purge ${NAME}

clean:
rm -rf charts
rm -rf ${NAME}*.tgz

release: clean
helm dependency build
helm lint
helm init --client-only
helm package .
curl --fail -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts
rm -rf ${NAME}*.tgz%

tag:
ifeq ($(OS),Darwin)
sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
sed -i "" -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml
else ifeq ($(OS),Linux)
sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/REPLACE_ME_DOCKER_REGISTRY_ORG\/REPLACE_ME_APP_NAME|" values.yaml
sed -i -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml
else
echo "platfrom $(OS) not supported to release from"
exit -1
endif
git add --all
git commit -m "chore: release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed
git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)"
git push origin v$(RELEASE_VERSION)
1 change: 1 addition & 0 deletions packs/maven-java17/charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Java 14 application
4 changes: 4 additions & 0 deletions packs/maven-java17/charts/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Get the application URL by running these commands:

kubectl get ingress {{ template "fullname" . }}
16 changes: 16 additions & 0 deletions packs/maven-java17/charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
66 changes: 66 additions & 0 deletions packs/maven-java17/charts/templates/canary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{- if .Values.canary.enabled }}
apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
name: {{ template "fullname" . }}
labels:
draft: {{ default "draft-app" .Values.draft }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- if .Values.canary.labels }}
{{ toYaml .Values.canary.labels | indent 4 }}
{{- end }}
spec:
provider: istio
targetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "fullname" . }}
progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }}
{{- if .Values.hpa.enabled }}
autoscalerRef:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
name: {{ template "fullname" . }}
{{- end }}
service:
port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
gateways:
- {{ template "fullname" . }}
hosts:
- {{ .Values.canary.host | default (printf "%s%s%s" .Values.service.name .Values.jxRequirements.ingress.namespaceSubDomain .Values.jxRequirements.ingress.domain) }}
analysis:
interval: {{ .Values.canary.analysis.interval }}
threshold: {{ .Values.canary.analysis.threshold }}
maxWeight: {{ .Values.canary.analysis.maxWeight }}
stepWeight: {{ .Values.canary.analysis.stepWeight }}
metrics:
- name: latency
templateRef:
name: latency
namespace: istio-system
thresholdRange:
max: {{ .Values.canary.analysis.metrics.latency.threshold }}
interval: {{ .Values.canary.analysis.metrics.latency.interval | quote }}

---

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: {{ template "fullname" . }}
{{- if .Values.canary.gatewayLabels }}
labels:
{{ toYaml .Values.canary.gatewayLabels | indent 4 }}
{{- end }}
spec:
selector:
istio: ingressgateway
servers:
- port:
number: {{ .Values.service.externalPort }}
name: http
protocol: HTTP
hosts:
- {{ .Values.canary.host | default (printf "%s%s%s" .Values.service.name .Values.jxRequirements.ingress.namespaceSubDomain .Values.jxRequirements.ingress.domain) }}
{{- end }}
Loading

0 comments on commit 22ec70a

Please sign in to comment.