Compare commits
38 Commits
feature/k8
...
feature/pa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b739431651 | ||
|
|
b78ed1bcf6 | ||
|
|
00154a9e93 | ||
|
|
df13897a25 | ||
|
|
94db5c3efa | ||
|
|
17291abd2e | ||
|
|
d72a06f005 | ||
|
|
0bd74fa092 | ||
|
|
ac5c2b2106 | ||
|
|
ddce6d49ac | ||
|
|
ba406dd3a9 | ||
|
|
997013ad3f | ||
|
|
9fb3cfce01 | ||
|
|
58f1a5cf3e | ||
|
|
ee4f86c17a | ||
|
|
94609f4347 | ||
|
|
b10e682c11 | ||
|
|
12135903ab | ||
|
|
982fdd2438 | ||
|
|
df3a84426f | ||
|
|
b39bdc130f | ||
|
|
7002a942d3 | ||
|
|
5ee75f88dd | ||
|
|
6a2de89154 | ||
|
|
f6850fa35f | ||
|
|
31ecf84171 | ||
|
|
9b90eae493 | ||
|
|
4056c657d3 | ||
|
|
a5ed743178 | ||
|
|
8afb0e62a3 | ||
|
|
2b4921b5c8 | ||
|
|
4f06b352e5 | ||
|
|
c425e899d4 | ||
|
|
15d6bf124f | ||
|
|
b1440f702b | ||
|
|
90bb5d1ddf | ||
|
|
302893976c | ||
|
|
a4a55e133b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea/*
|
.idea/*
|
||||||
|
target/
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
FROM openjdk:8-jre-alpine
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
COPY ./target/java-maven-app-*.jar /usr/app/
|
|
||||||
WORKDIR /usr/app
|
|
||||||
|
|
||||||
CMD java -jar java-maven-app-*.jar
|
|
||||||
53
Jenkinsfile
vendored
53
Jenkinsfile
vendored
@@ -2,68 +2,25 @@
|
|||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
tools {
|
|
||||||
maven 'Maven'
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
stage('increment version') {
|
stage('test') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo 'incrementing app version...'
|
echo "Testing the application..."
|
||||||
sh 'mvn build-helper:parse-version versions:set \
|
|
||||||
-DnewVersion=\\\${parsedVersion.majorVersion}.\\\${parsedVersion.minorVersion}.\\\${parsedVersion.nextIncrementalVersion} \
|
|
||||||
versions:commit'
|
|
||||||
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
|
|
||||||
def version = matcher[0][1]
|
|
||||||
env.IMAGE_NAME = "$version-$BUILD_NUMBER"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('build app') {
|
stage('build') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "building the application..."
|
echo "Building the application..."
|
||||||
sh 'mvn clean package'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('build image') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo "building the docker image..."
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
|
||||||
sh "docker build -t nanajanashia/demo-app:${IMAGE_NAME} ."
|
|
||||||
sh "echo $PASS | docker login -u $USER --password-stdin"
|
|
||||||
sh "docker push nanajanashia/demo-app:${IMAGE_NAME}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('deploy') {
|
stage('deploy') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
withKubeConfig([credentialsId: 'k8s-credentials', serverUrl: 'https://7293fae4-4c9d-4629-bc82-262d0a2b8e3c.eu-central-2.linodelke.net']) {
|
echo "Deploying the application..."
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
|
||||||
sh "kubectl create secret docker-registry my-registry-key --docker-server=docker.io --docker-username=$USER --docker-password=$PASS"
|
|
||||||
}
|
|
||||||
sh 'envsubst < kubernetes/deployment.yaml | kubectl apply -f -'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('commit version update') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'gitlab-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
|
||||||
// git config here for the first time run
|
|
||||||
sh 'git config --global user.email "jenkins@example.com"'
|
|
||||||
sh 'git config --global user.name "jenkins"'
|
|
||||||
|
|
||||||
sh "git remote set-url origin https://${USER}:${PASS}@gitlab.com/nanuchi/java-maven-app.git"
|
|
||||||
sh 'git add .'
|
|
||||||
sh 'git commit -m "ci: version bump"'
|
|
||||||
sh 'git push origin HEAD:jenkins-jobs'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: java-maven-app
|
|
||||||
labels:
|
|
||||||
app: java-maven-app
|
|
||||||
spec:
|
|
||||||
replicas: 2
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: java-maven-app
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: java-maven-app
|
|
||||||
spec:
|
|
||||||
imagePullSecrets:
|
|
||||||
- name: my-registry-key
|
|
||||||
containers:
|
|
||||||
- name: java-maven-app
|
|
||||||
image: nanajanashia/demo-app:$IMAGE_NAME
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: java-maven-app
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: java-maven-app
|
|
||||||
ports:
|
|
||||||
- protocol: TCP
|
|
||||||
port: 80
|
|
||||||
targetPort: 8080
|
|
||||||
19
pom.xml
19
pom.xml
@@ -6,24 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.example</groupId>
|
<groupId>com.example</groupId>
|
||||||
<artifactId>java-maven-app</artifactId>
|
<artifactId>java-maven-app</artifactId>
|
||||||
<version>1.1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>2.3.5.RELEASE</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>repackage</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
def buildJar() {
|
|
||||||
echo "building the application..."
|
|
||||||
sh 'mvn package'
|
|
||||||
}
|
|
||||||
|
|
||||||
def buildImage() {
|
|
||||||
echo "building the docker image..."
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
|
||||||
sh 'docker build -t nanajanashia/demo-app:jma-2.0 .'
|
|
||||||
sh "echo $PASS | docker login -u $USER --password-stdin"
|
|
||||||
sh 'docker push nanajanashia/demo-app:jma-2.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def deployApp() {
|
|
||||||
echo 'deploying the application...'
|
|
||||||
}
|
|
||||||
|
|
||||||
return this
|
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user