Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jiwei-api
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马天浩
jiwei-api
Commits
8c14c0e3
Commit
8c14c0e3
authored
Aug 13, 2020
by
matianhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[配置文件] <add> 新增jenkins和docker配置文件
parent
1a73d83d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
0 deletions
+137
-0
citybrain-webapi-deployment.yaml
citybrain-webapi-deployment.yaml
+48
-0
dockerfile
dockerfile
+16
-0
jenkinsfile
jenkinsfile
+73
-0
No files found.
citybrain-webapi-deployment.yaml
0 → 100644
View file @
8c14c0e3
---
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
jiwei-api
namespace
:
default
labels
:
app
:
jiwei-api
spec
:
replicas
:
1
selector
:
matchLabels
:
app
:
jiwei-api
template
:
metadata
:
labels
:
app
:
jiwei-api
spec
:
nodeSelector
:
role2
:
worker
imagePullSecrets
:
-
name
:
image
containers
:
-
name
:
jiwei-api
image
:
reg.watone.local/cap/jiwei-api:latest
imagePullPolicy
:
"
Always"
ports
:
-
containerPort
:
1209
env
:
-
name
:
PROFILES
value
:
profiles
---
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
jiwei-api
namespace
:
default
labels
:
app
:
jiwei-api
spec
:
type
:
NodePort
ports
:
-
port
:
1209
targetPort
:
1209
nodePort
:
31209
selector
:
app
:
jiwei-api
dockerfile
0 → 100644
View file @
8c14c0e3
FROM
openjdk:8-alpine
LABEL
app="jiwei-api" version="0.0.1" o="watone" a="caosx"
RUN
mkdir
-p
/data/logs
ENV
LOG_PATH=/data/logs
ENV
TZ='Asia/Shanghai'
ARG
APP_NAME_SRC=""
ENV
APP_NAME_SRC=${APP_NAME_SRC}
ENV
APP_NAME_DST=jiwei-api-0.0.1-SNAPSHOT.jar
COPY
target/${APP_NAME_SRC} ${APP_NAME_DST}
EXPOSE
1209
ENTRYPOINT
java -jar -Dspring.profiles.active=${PROFILES} /${APP_NAME_DST}
jenkinsfile
0 → 100644
View file @
8c14c0e3
pipeline
{
agent
any
stages
{
stage
(
'Git Checkout'
){
steps
{
checkout
([
$class
:
'GitSCM'
,
branches:
[[
name:
"$BRANCHES"
]],
doGenerateSubmoduleConfigurations:
false
,
extensions:
[],
submoduleCfg:
[],
userRemoteConfigs:
[[
credentialsId:
'df5d99a0-9b4f-4ac1-aaaa-6e0865e0cd67'
,
url:
'git@47.111.5.200:math/jiwei-api.git'
]]])
}
}
stage
(
'Maven Build'
){
steps
{
sh
"/wtdisk/apache-maven-3.6.3/bin/mvn clean -U package -Dmaven.test.skip=true"
// sh "/usr/local/maven/bin/mvn clean -U package -P${PROFILES} -DVERSION=${VERSION} -Dmaven.test.skip=true"
}
}
stage
(
'Build & Push Image'
){
steps
{
sh
'''
docker login -u ${ACCOUNT} -p ${PASSWD} ${REGISTRY}
docker build -t ${REGISTRY}/${PROJECT_NAME}/${IMAGE_NAME}:${VERSION} --build-arg APP_NAME_SRC=`ls target/*.jar |cut -d '/' -f2` -f dockerfile .
docker push ${REGISTRY}/${PROJECT_NAME}/${IMAGE_NAME}:${VERSION}
'''
}
}
stage
(
'Deploy to k8s'
)
{
steps
{
script
{
if
(
PROFILES
==
'prod'
)
{
echo
'接下来进行生产项目的发布...'
sh
'''
sed -i "/image/{s/latest/${VERSION}/}" citybrain-webapi-deployment.yaml
sed -i "/profiles/{s/profiles/${PROFILES}/}" citybrain-webapi-deployment.yaml
sshpass scp citybrain-webapi-deployment.yaml root@172.18.39.191:/root/caosx/yml
sshpass ssh root@172.18.39.191 'kubectl apply -f /root/caosx/yml/citybrain-webapi-deployment.yaml'
'''
// kubernetesDeploy configs: 'deploy.yaml', kubeConfig: [path: ''], kubeconfigId: '3ab9d4b4-ffb9-44af-ab49-c17b64161198', secretName: '', ssh: [sshCredentialsId: '*', sshServer: ''], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']
}
// if ( PROFILES == 'test' ) {
// echo '接下来进行测试项目的发布...'
// sh '''
// sed -i "/image/{s/latest/${VERSION}/}" deploy.yaml
// sed -i "/PROFILES/{s/profiles/${PROFILES}/}" deploy.yaml
// '''
// kubernetesDeploy configs: 'deploy.yaml', kubeConfig: [path: ''], kubeconfigId: '3ab9d4b4-ffb9-44af-ab49-c17b64161198', secretName: '', ssh: [sshCredentialsId: '*', sshServer: ''], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']
// }
// if ( PROFILES == 'pre' ) {
// echo '接下来进行预发项目的发布...'
// sh '''
// sed -i "/image/{s/latest/${VERSION}/}" deploy.yaml
// sed -i "/PROFILES/{s/profiles/${PROFILES}/}" deploy.yaml
// '''
// kubernetesDeploy configs: 'deploy.yaml', kubeConfig: [path: ''], kubeconfigId: '3ab9d4b4-ffb9-44af-ab49-c17b64161198', secretName: '', ssh: [sshCredentialsId: '*', sshServer: ''], textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://']
// }
}
}
}
stage
(
'Post-Build'
)
{
steps
{
script
{
currentBuild
.
description
=
"${VERSION}"
}
}
}
}
}
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