Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
spring-music
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
卢浩元
spring-music
Commits
04591a3f
Commit
04591a3f
authored
May 20, 2019
by
lusyoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加Jenkinsfile、Dockerfile以及logback配置
parent
fe15454c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
5 deletions
+156
-5
Dockerfile
Dockerfile
+6
-0
Jenkinsfile
Jenkinsfile
+73
-0
build.gradle
build.gradle
+6
-1
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+2
-1
application.yml
src/main/resources/application.yml
+5
-3
logback-spring.xml
src/main/resources/logback-spring.xml
+64
-0
No files found.
Dockerfile
0 → 100644
View file @
04591a3f
FROM
harbor.k2software.com.cn/build/openjdk:8-alpine
COPY
build/libs/spring-music.jar /opt
CMD
["java", "-jar" "-Dspring.profiles.active=mysql", "/opt/spring-music.jar"]
\ No newline at end of file
Jenkinsfile
0 → 100644
View file @
04591a3f
#
!
/usr/
bin
/
env
groovy
def
projectProperties
=
[
[
$class
:
'BuildDiscarderProperty'
,
strategy:
[
$class
:
'LogRotator'
,
numToKeepStr:
'5'
]],
parameters
([
string
(
name:
'DOCKER_USER'
,
defaultValue:
'admin'
,
description:
'docker用户名'
),
string
(
name:
'DOCKER_PASSWORD'
,
defaultValue:
'K2pass!!'
,
description:
'docker用户密码'
),
string
(
name:
'REGISTRY_URL'
,
defaultValue:
'harbor.172.18.10.12.nip.io'
,
description:
'docker仓库地址'
)
])
]
properties
(
projectProperties
)
def
label
=
"mypod-${UUID.randomUUID().toString()}"
podTemplate
(
label:
label
,
cloud:
'kubernetes'
,
containers:
[
containerTemplate
(
name:
'maven'
,
image:
'harbor.k2software.com.cn/build/gradle:5.4-alpine'
,
command:
'cat'
,
ttyEnabled:
true
),
containerTemplate
(
name:
'docker'
,
image:
'harbor.k2software.com.cn/build/gdocker:latest'
,
command:
'cat'
,
ttyEnabled:
true
),
containerTemplate
(
name:
'helm'
,
image:
'harbor.k2software.com.cn/build/helm:v2.11.0'
,
command:
'cat'
,
ttyEnabled:
true
,
envVars:
[
envVar
(
key:
'KUBECONFIG'
,
value:
'/root/.kube/config'
)])
],
volumes:
[
hostPathVolume
(
hostPath:
'/var/run/docker.sock'
,
mountPath:
'/var/run/docker.sock'
),
hostPathVolume
(
hostPath:
'/root/.kube'
,
mountPath:
'/root/.kube'
),
hostPathVolume
(
hostPath:
'/root/.helm'
,
mountPath:
'/home/jenkins/.helm'
)
])
{
node
(
label
)
{
def
version
=
"1.0"
stage
(
'checkout'
)
{
checkout
scm
sh
'printenv'
}
container
(
'maven'
)
{
stage
(
'pacakge'
)
{
sh
"gradle clean assemble"
}
}
container
(
'docker'
)
{
stage
(
'docker-login'
)
{
//REGISTRY_URL私有仓库地址,也可使用官方地址:docker.io
sh
"docker login -u ${params.DOCKER_USER} -p ${params.DOCKER_PASSWORD} ${params.REGISTRY_URL}"
}
stage
(
'docker-build'
)
{
sh
"docker build . -t ${params.REGISTRY_URL}/library/spring-music:${version}-${env.BUILD_ID}"
}
stage
(
'docker-push'
)
{
sh
"docker push ${params.REGISTRY_URL}/library/spring-music:${version}-${env.BUILD_ID}"
}
}
// container('helm') {
// stage('helm deploy') {
// sh ""
// sh "helm upgrade --install spring-music chart/"
// }
// }
}
}
// vim: ft=groovy
\ No newline at end of file
build.gradle
View file @
04591a3f
...
...
@@ -5,9 +5,13 @@ buildscript {
}
repositories
{
maven
{
url
"https://nexus.k2software.com.cn/repository/maven-public/"
}
jcenter
()
mavenCentral
()
maven
{
url
"https://repo.spring.io/plugins-release"
}
// maven { url "https://repo.spring.io/plugins-release" }
}
dependencies
{
...
...
@@ -59,6 +63,7 @@ dependencies {
compile
"org.webjars:angular-ui-bootstrap:0.10.0-1"
compile
"org.webjars:jquery:2.1.0-2"
compile
"net.logstash.logback:logstash-logback-encoder:5.1"
// Oracle - uncomment one of the following after placing driver in ./libs
// compile files('libs/ojdbc8.jar')
// compile files('libs/ojdbc7.jar')
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
04591a3f
#Mon May 20 17:34:29 CST 2019
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.4-
bin
.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.4-
all
.zip
src/main/resources/application.yml
View file @
04591a3f
...
...
@@ -12,10 +12,10 @@ management:
spring
:
profiles
:
mysql
datasource
:
url
:
"
jdbc:mysql://
localhost
/music"
url
:
"
jdbc:mysql://
mysql-service:3306
/music"
driver-class-name
:
com.mysql.jdbc.Driver
username
:
password
:
username
:
root
password
:
K2pass
jpa
:
properties
:
hibernate
:
...
...
@@ -33,3 +33,5 @@ spring:
properties
:
hibernate
:
dialect
:
org.hibernate.dialect.ProgressDialect
---
src/main/resources/logback-spring.xml
0 → 100644
View file @
04591a3f
<?xml version="1.0" encoding="UTF-8" ?>
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/defaults.xml"
/>
<springProperty
scope=
"context"
name=
"springAppName"
source=
"spring.application.name"
/>
<!-- 日志在工程中的输出位置 -->
<property
name=
"LOG_FILE"
value=
"${BUILD_FOLDER:-build}/${springAppName}"
/>
<!-- 控制台的日志输出样式 -->
<property
name=
"CONSOLE_LOG_PATTERN"
value=
"%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"
/>
<!-- 控制台输出 -->
<appender
name=
"console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
</filter>
<!-- 日志输出编码 -->
<encoder>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
<charset>
utf8
</charset>
</encoder>
</appender>
<!-- 为logstash输出的JSON格式的Appender -->
<appender
name=
"logstash"
class=
"net.logstash.logback.appender.LogstashTcpSocketAppender"
>
<destination>
192.168.11.86:9250
</destination>
<!-- 日志输出编码 -->
<encoder
class=
"net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"
>
<providers>
<timestamp>
<timeZone>
UTC
</timeZone>
</timestamp>
<pattern>
<pattern>
{
"severity": "%level",
"service": "${springAppName:-}",
"trace": "%X{X-B3-TraceId:-}",
"span": "%X{X-B3-SpanId:-}",
"exportable": "%X{X-Span-Export:-}",
"pid": "${PID:-}",
"thread": "%thread",
"class": "%logger{40}",
"rest": "%message"
}
</pattern>
</pattern>
</providers>
</encoder>
</appender>
<!-- 日志输出级别 -->
<root
level=
"INFO"
>
<appender-ref
ref=
"console"
/>
<appender-ref
ref=
"logstash"
/>
</root>
</configuration>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment