Compare commits
12 Commits
master
...
jenkins-sh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7e9360e2c | ||
|
|
6b1d998791 | ||
|
|
922c8df4c6 | ||
|
|
946909a1b0 | ||
|
|
5aab8caed6 | ||
|
|
63a5e576a8 | ||
|
|
aa6f394e65 | ||
|
|
15a05dc886 | ||
|
|
81b557f424 | ||
|
|
6e6e1fdcb6 | ||
|
|
75f780bd0c | ||
|
|
6a5572a5f7 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
.idea/*
|
||||
target
|
||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM openjdk:8-jre-alpine
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
COPY ./target/java-maven-app-1.0-SNAPSHOT.jar /usr/app/
|
||||
WORKDIR /usr/app
|
||||
|
||||
ENTRYPOINT ["java", "-jar", "java-maven-app-1.0-SNAPSHOT.jar"]
|
||||
26
Jenkinsfile
vendored
26
Jenkinsfile
vendored
@@ -1,7 +1,20 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
library identifier: 'jenkins-shared-library@master', retriever: modernSCM(
|
||||
[$class: 'GitSCMSource',
|
||||
remote: 'https://gitlab.com/nanuchi/jenkins-shared-library.git',
|
||||
credentialsId: 'gitlab-credentials'
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def gv
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
tools {
|
||||
maven 'Maven'
|
||||
}
|
||||
stages {
|
||||
stage("init") {
|
||||
steps {
|
||||
@@ -13,24 +26,23 @@ pipeline {
|
||||
stage("build jar") {
|
||||
steps {
|
||||
script {
|
||||
echo "building jar"
|
||||
//gv.buildJar()
|
||||
buildJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("build image") {
|
||||
stage("build and push image") {
|
||||
steps {
|
||||
script {
|
||||
echo "building image"
|
||||
//gv.buildImage()
|
||||
buildImage 'nanajanashia/demo-app:jma-3.0'
|
||||
dockerLogin()
|
||||
dockerPush 'nanajanashia/demo-app:jma-3.0'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("deploy") {
|
||||
steps {
|
||||
script {
|
||||
echo "deploying"
|
||||
//gv.deployApp()
|
||||
gv.deployApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
30
pom.xml
30
pom.xml
@@ -6,35 +6,7 @@
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>java-maven-app</artifactId>
|
||||
<version>1.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>
|
||||
|
||||
<!-- to handle any Java version mismatch, add the following configuration for maven-compiler-plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -1,17 +1,3 @@
|
||||
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...'
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<!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