6 Commits

Author SHA1 Message Date
Nana Janashia
31ae1c5153 Add simple UI 2021-07-12 12:32:27 +02:00
Nana Janashia
b128506eec Update Jenkinsfile 2021-01-04 10:14:43 +00: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 16 additions and 34 deletions

39
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,30 +14,18 @@ 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 { environment {
script { AWS_ACCESS_KEY_ID = credentials('jenkins_aws_access_key_id')
echo 'deploying docker image to EC2...' AWS_SECRET_ACCESS_KEY = credentials('jenkins_aws_secret_access_key')
}
} }
}
stage('commit version update') {
steps { steps {
script { script {
withCredentials([usernamePassword(credentialsId: 'gitlab-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) { echo 'deploying docker image...'
sh "git remote set-url origin https://${USER}:${PASS}@gitlab.com/nanuchi/java-maven-app.git" sh 'kubectl create deployment nginx-deployment --image=nginx'
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>