Compare commits
6 Commits
jenkins-jo
...
deploy-to-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2a8032539 | ||
|
|
61b3c16c60 | ||
|
|
0a40971e52 | ||
|
|
ba11b6ecc8 | ||
|
|
127fe8818c | ||
|
|
322a9fb1b9 |
39
Jenkinsfile
vendored
39
Jenkinsfile
vendored
@@ -2,28 +2,11 @@
|
|||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
tools {
|
|
||||||
maven 'Maven'
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
stage('increment version') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
echo 'incrementing app version...'
|
|
||||||
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 app') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "building the application..."
|
echo "building the application..."
|
||||||
sh 'mvn clean package'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,30 +14,16 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "building the docker image..."
|
echo "building the docker image..."
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', 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 {
|
||||||
echo 'deploying docker image to EC2...'
|
echo 'deploying docker image...'
|
||||||
}
|
withKubeConfig([credentialsId: 'lke-credentials', serverUrl: 'https://79fa9228-1d11-47ec-870b-33106d53122b.eu-central-2.linodelke.net']) {
|
||||||
}
|
sh 'kubectl create deployment nginx-deployment --image=nginx'
|
||||||
}
|
}
|
||||||
stage('commit version update') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'gitlab-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
|
||||||
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'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main/resources/static/index.html
Normal file
11
src/main/resources/static/index.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>MyApp</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Welcome to Java Maven Application</h1>
|
||||||
|
<!-- add image here <img src="" width="" /> -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user