修改
This commit is contained in:
parent
ccefd62a9e
commit
d17c3e73a2
86
Jenkinsfile
vendored
Normal file
86
Jenkinsfile
vendored
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
node {
|
||||||
|
label 'nodejs'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('拉取代码') {
|
||||||
|
agent none
|
||||||
|
steps {
|
||||||
|
container('nodejs') {
|
||||||
|
git(url: 'https://gitee.com/forget_the_bright/jeecg-boot-vue.git', credentialsId: 'wanghao-gitee', branch: 'master', changelog: true, poll: false)
|
||||||
|
sh 'ls -al'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('项目编译') {
|
||||||
|
agent none
|
||||||
|
steps {
|
||||||
|
container('nodejs') {
|
||||||
|
sh 'npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/'
|
||||||
|
sh 'npm install --registry=https://registry.npm.taobao.org'
|
||||||
|
sh 'npm run build'
|
||||||
|
sh 'ls'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('构建镜像') {
|
||||||
|
agent none
|
||||||
|
steps {
|
||||||
|
container('nodejs') {
|
||||||
|
sh 'ls'
|
||||||
|
sh 'docker build -t enfi-boot-vue:latest -f Dockerfile .'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('推送镜像') {
|
||||||
|
agent none
|
||||||
|
steps {
|
||||||
|
container('nodejs') {
|
||||||
|
withCredentials([usernamePassword(credentialsId : 'aliyun-docker-registry' ,usernameVariable : 'DOCKER_USER_VAR' ,passwordVariable : 'DOCKER_PWD_VAR' ,)]) {
|
||||||
|
sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
|
||||||
|
sh 'docker tag enfi-boot-vue:latest $REGISTRY/$DOCKERHUB_NAMESPACE/enfi-boot-vue:SNAPSHOT-$BUILD_NUMBER'
|
||||||
|
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/enfi-boot-vue:SNAPSHOT-$BUILD_NUMBER'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('部署到dev环境') {
|
||||||
|
agent none
|
||||||
|
steps {
|
||||||
|
kubernetesDeploy(configs: 'deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//1、配置全系统的邮件: 全系统的监控
|
||||||
|
//2、修改ks-jenkins的配置,里面的邮件; 流水线发邮件
|
||||||
|
/* stage('发送确认邮件') {
|
||||||
|
agent none
|
||||||
|
steps {
|
||||||
|
mail(to: '17512080612@163.com', subject: 'yygh-admin构建结果', body: "构建成功了 $BUILD_NUMBER")
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
}
|
||||||
|
environment {
|
||||||
|
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
|
||||||
|
GITHUB_CREDENTIAL_ID = 'github-id'
|
||||||
|
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
|
||||||
|
REGISTRY = 'registry.cn-beijing.aliyuncs.com'
|
||||||
|
DOCKERHUB_NAMESPACE = 'wh_k8s'
|
||||||
|
GITHUB_ACCOUNT = 'kubesphere'
|
||||||
|
APP_NAME = 'devops-java-sample'
|
||||||
|
ALIYUNHUB_NAMESPACE = 'wh_k8s'
|
||||||
|
}
|
||||||
|
}
|
67
deploy/enfi-boot-vue-deployment.yml
Normal file
67
deploy/enfi-boot-vue-deployment.yml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: enfi-boot-vue
|
||||||
|
name: enfi-boot-vue
|
||||||
|
namespace: wang-project #一定要写名称空间
|
||||||
|
spec:
|
||||||
|
progressDeadlineSeconds: 600
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: enfi-boot-vue
|
||||||
|
strategy:
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 50%
|
||||||
|
maxUnavailable: 50%
|
||||||
|
type: RollingUpdate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: enfi-boot-vue
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: aliyun-docker-hub #提前在项目下配置访问阿里云的账号密码
|
||||||
|
containers:
|
||||||
|
- image: $REGISTRY/$ALIYUNHUB_NAMESPACE/yygh-admin:SNAPSHOT-$BUILD_NUMBER
|
||||||
|
# readinessProbe:
|
||||||
|
# httpGet:
|
||||||
|
# path: /actuator/health
|
||||||
|
# port: 8080
|
||||||
|
# timeoutSeconds: 10
|
||||||
|
# failureThreshold: 30
|
||||||
|
# periodSeconds: 5
|
||||||
|
imagePullPolicy: Always
|
||||||
|
name: app
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
protocol: TCP
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: 300m
|
||||||
|
memory: 300Mi
|
||||||
|
terminationMessagePath: /dev/termination-log
|
||||||
|
terminationMessagePolicy: File
|
||||||
|
dnsPolicy: ClusterFirst
|
||||||
|
restartPolicy: Always
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: enfi-boot-vue
|
||||||
|
name: enfi-boot-vue
|
||||||
|
namespace: wang-project
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: 80
|
||||||
|
nodePort: 32248
|
||||||
|
selector:
|
||||||
|
app: enfi-boot-vue
|
||||||
|
sessionAffinity: None
|
||||||
|
type: NodePort
|
Loading…
x
Reference in New Issue
Block a user