6 Commits

Author SHA1 Message Date
Nana Janashia
f2a8032539 Add simple UI 2021-07-12 12:33:29 +02:00
Nana Janashia
61b3c16c60 add kubectl deploy to lke 2020-12-04 19:32:41 +01:00
Nana Janashia
0a40971e52 add kubectl deploy step 2020-12-04 19:11:10 +01:00
Nana Janashia
ba11b6ecc8 revert 2020-12-04 19:00:41 +01:00
Nana Janashia
127fe8818c add kubectl create 2020-12-04 16:46:59 +01:00
Nana Janashia
322a9fb1b9 add new feature 2020-12-04 16:22:34 +01:00
2 changed files with 15 additions and 35 deletions

37
Jenkinsfile vendored
View File

@@ -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,29 +14,15 @@ 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'
} }
} }
} }

View 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>