Compare commits
6 Commits
complete-p
...
deploy-on-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31ae1c5153 | ||
|
|
b128506eec | ||
|
|
0a40971e52 | ||
|
|
ba11b6ecc8 | ||
|
|
127fe8818c | ||
|
|
322a9fb1b9 |
39
Jenkinsfile
vendored
39
Jenkinsfile
vendored
@@ -2,28 +2,11 @@
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
tools {
|
||||
maven 'Maven'
|
||||
}
|
||||
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') {
|
||||
steps {
|
||||
script {
|
||||
echo "building the application..."
|
||||
sh 'mvn clean package'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,30 +14,18 @@ pipeline {
|
||||
steps {
|
||||
script {
|
||||
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') {
|
||||
steps {
|
||||
script {
|
||||
echo 'deploying docker image to EC2...'
|
||||
}
|
||||
environment {
|
||||
AWS_ACCESS_KEY_ID = credentials('jenkins_aws_access_key_id')
|
||||
AWS_SECRET_ACCESS_KEY = credentials('jenkins_aws_secret_access_key')
|
||||
}
|
||||
}
|
||||
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'
|
||||
}
|
||||
echo 'deploying docker image...'
|
||||
sh 'kubectl create deployment nginx-deployment --image=nginx'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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