Compare commits
26 Commits
feature/je
...
jenkins-sh
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7e9360e2c | ||
|
|
6b1d998791 | ||
|
|
922c8df4c6 | ||
|
|
946909a1b0 | ||
|
|
5aab8caed6 | ||
|
|
63a5e576a8 | ||
|
|
aa6f394e65 | ||
|
|
15a05dc886 | ||
|
|
81b557f424 | ||
|
|
6e6e1fdcb6 | ||
|
|
75f780bd0c | ||
|
|
6a5572a5f7 | ||
|
|
d7839d4033 | ||
|
|
af78bcdf1e | ||
|
|
5a4e789475 | ||
|
|
9969d8b2cf | ||
|
|
3e129808aa | ||
|
|
f03d95e413 | ||
|
|
c8f9061ef6 | ||
|
|
6804a58c01 | ||
|
|
5ef50d2628 | ||
|
|
1c02e35f97 | ||
|
|
f298808592 | ||
|
|
a14a9d4f9a | ||
|
|
d267e0d112 | ||
|
|
833dd401b3 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
.idea/*
|
||||
target
|
||||
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
@@ -7,46 +7,42 @@ library identifier: 'jenkins-shared-library@master', retriever: modernSCM(
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def gv
|
||||
|
||||
pipeline {
|
||||
agent any
|
||||
tools {
|
||||
maven 'Maven'
|
||||
}
|
||||
environment {
|
||||
IMAGE_NAME = 'nanajanashia/demo-app:java-maven-2.0'
|
||||
}
|
||||
stages {
|
||||
stage('build app') {
|
||||
stage("init") {
|
||||
steps {
|
||||
script {
|
||||
gv = load "script.groovy"
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("build jar") {
|
||||
steps {
|
||||
script {
|
||||
echo 'building application jar...'
|
||||
buildJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('build image') {
|
||||
stage("build and push image") {
|
||||
steps {
|
||||
script {
|
||||
echo 'building docker image...'
|
||||
buildImage(env.IMAGE_NAME)
|
||||
buildImage 'nanajanashia/demo-app:jma-3.0'
|
||||
dockerLogin()
|
||||
dockerPush(env.IMAGE_NAME)
|
||||
dockerPush 'nanajanashia/demo-app:jma-3.0'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('deploy') {
|
||||
stage("deploy") {
|
||||
steps {
|
||||
script {
|
||||
echo 'deploying docker image to EC2...'
|
||||
|
||||
def shellCmd = "bash ./server-cmds.sh ${IMAGE_NAME}"
|
||||
def ec2Instance = "ec2-user@35.180.251.121"
|
||||
|
||||
sshagent(['ec2-server-key']) {
|
||||
sh "scp -o StrictHostKeyChecking=no server-cmds.sh ${ec2Instance}:/home/ec2-user"
|
||||
sh "scp -o StrictHostKeyChecking=no docker-compose.yaml ${ec2Instance}:/home/ec2-user"
|
||||
sh "ssh -o StrictHostKeyChecking=no ${ec2Instance} ${shellCmd}"
|
||||
}
|
||||
gv.deployApp()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
java-maven-app:
|
||||
image: ${IMAGE}
|
||||
ports:
|
||||
- 8080:8080
|
||||
postgres:
|
||||
image: postgres:13
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=my-pwd
|
||||
21
pom.xml
21
pom.xml
@@ -8,27 +8,6 @@
|
||||
<artifactId>java-maven-app</artifactId>
|
||||
<version>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>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
5
script.groovy
Normal file
5
script.groovy
Normal file
@@ -0,0 +1,5 @@
|
||||
def deployApp() {
|
||||
echo 'deploying the application...'
|
||||
}
|
||||
|
||||
return this
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export IMAGE=$1
|
||||
docker-compose -f docker-compose.yaml up --detach
|
||||
echo "success"
|
||||
@@ -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>
|
||||
@@ -1,16 +0,0 @@
|
||||
import com.example.Application;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void testApp() {
|
||||
Application myApp = new Application();
|
||||
|
||||
String result = myApp.getStatus();
|
||||
|
||||
assertEquals("OK", result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user