1 Star 0 Fork 0

yupengzheng/博客网站PC

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Jenkinsfile-all-fxtest2.groovy 5.20 KB
一键复制 编辑 原始数据 按行查看 历史
// 需要在jenkins的Credentials设置中配置jenkins-aliyun-creds、jenkins-k8s-config参数
pipeline {
agent any
environment {
HARBOR_CREDS = credentials('jenkins-aliyun-creds')
K8S_CONFIG = credentials('HUAWEI_K8S_CERT')
GIT_TAG = sh(returnStdout: true, script: 'git describe --tags --always').trim()
}
parameters {
string(name: 'Aliyun_HOST', defaultValue: 'registry.cn-zhangjiakou.aliyuncs.com/sz_south1', description: '阿里云仓库地址')
string(name: 'K8S_NAMESPACE', defaultValue: 'fxtest2', description: 'k8s的namespace名称')
string(name: 'SSL_NAME', defaultValue: 'platformcenter.net-ssl-ingress-secret', description: 'SSL密钥名称')
string(name: 'WINDOW_CONFIG_HOST', defaultValue: 'https://entry-mch2.platformcenter.net/', description: '车主域名配置')
string(name: 'ROLE_NAME1', defaultValue: '厂家', description: '配置1')
string(name: 'ROLE_NAME2', defaultValue: '经销商', description: '配置2')
string(name: 'ROLE_NAME3', defaultValue: '物业', description: '配置3')
string(name: 'SOCKET_HOST', defaultValue: 'wss://entry-web-notify2.platformcenter.net/webWs', description: 'ws连接地址')
}
stages {
stage('Node Build') {
when {
expression {
env.GIT_TAG != null
}
}
agent any
steps {
sh "npm --prefix ./simpleWay install"
sh "npm --prefix ./simpleWay run build"
sh "npm --prefix ./simpleWay run lazyJs"
sh "ls -l dist/*"
stash includes: '**/dist/**', name: 'app'
}
}
stage('Docker Build') {
when {
allOf {
expression {
env.GIT_TAG != null
}
}
}
agent any
steps {
unstash 'app'
sh "docker build -t ${params.Aliyun_HOST}/manufactor:${GIT_TAG} ."
sh "docker push ${params.Aliyun_HOST}/manufactor:${GIT_TAG}"
sh "docker rmi ${params.Aliyun_HOST}/manufactor:${GIT_TAG}"
sh "docker build -t ${params.Aliyun_HOST}/m:${GIT_TAG} ."
sh "docker push ${params.Aliyun_HOST}/m:${GIT_TAG}"
sh "docker rmi ${params.Aliyun_HOST}/m:${GIT_TAG}"
sh "docker build -t ${params.Aliyun_HOST}/p:${GIT_TAG} ."
sh "docker push ${params.Aliyun_HOST}/p:${GIT_TAG}"
sh "docker rmi ${params.Aliyun_HOST}/p:${GIT_TAG}"
}
}
stage('Deploy') {
when {
allOf {
expression {
env.GIT_TAG != null
}
}
}
agent any
steps {
script {
def ver = ""
ver = sh(script: "grep version ${env.WORKSPACE}/static/config.js|awk -F: '{ print \$2 }'|awk -F, '{ print \$1 }'", returnStdout: true).trim()
sh "echo ${ver}"
// sh "mkdir -p ~/.kube"
// sh "echo ${K8S_CONFIG} | base64 -d > ~/.kube/config"
//第二套环境更新
sh "sed -e 's#{K8S_NAMESPACE}#fxtest2#g;s#{IMAGE_URL}#registry.cn-zhangjiakou.aliyuncs.com/sz_south1/manufactor#g;s#{IMAGE_TAG}#${GIT_TAG}#g;s#{APP_NAME}#manufactor2#g;s#{INGRESS_URL}#manufactor2.platformcenter.net#g;s#{INGRESS_URL_SSL}#platformcenter.net-ssl-ingress-secret#g;s#{ROLE_NAME}#${params.ROLE_NAME1}#g;s#{VERSION}#${GIT_TAG}#g;s#{WINDOW_CONFIG_HOST}#${WINDOW_CONFIG_HOST2}#g;s#{SOCKET_HOST}#${SOCKET_HOST2}#g' k8s-deployment-template.yml > k8s-deployment-manufactor2.yml"
sh "kubectl apply -f k8s-deployment-manufactor2.yml --namespace=fxtest2 --record --insecure-skip-tls-verify=true --kubeconfig huawei-config"
sh "sed -e 's#{K8S_NAMESPACE}#fxtest2#g;s#{IMAGE_URL}#registry.cn-zhangjiakou.aliyuncs.com/sz_south1/m#g;s#{IMAGE_TAG}#${GIT_TAG}#g;s#{APP_NAME}#m2#g;s#{INGRESS_URL}#m2.platformcenter.net#g;s#{INGRESS_URL_SSL}#platformcenter.net-ssl-ingress-secret#g;s#{ROLE_NAME}#${params.ROLE_NAME2}#g;s#{VERSION}#${GIT_TAG}#g;s#{WINDOW_CONFIG_HOST}#${WINDOW_CONFIG_HOST2}#g;s#{SOCKET_HOST}#${SOCKET_HOST2}#g' k8s-deployment-template.yml > k8s-deployment-m2.yml"
sh "kubectl apply -f k8s-deployment-m2.yml --namespace=fxtest2 --record --insecure-skip-tls-verify=true --kubeconfig huawei-config"
sh "sed -e 's#{K8S_NAMESPACE}#fxtest2#g;s#{IMAGE_URL}#registry.cn-zhangjiakou.aliyuncs.com/sz_south1/p#g;s#{IMAGE_TAG}#${GIT_TAG}#g;s#{APP_NAME}#p2#g;s#{INGRESS_URL}#p2.platformcenter.net#g;s#{INGRESS_URL_SSL}#platformcenter.net-ssl-ingress-secret#g;s#{ROLE_NAME}#${params.ROLE_NAME3}#g;s#{VERSION}#${GIT_TAG}#g;s#{WINDOW_CONFIG_HOST}#${WINDOW_CONFIG_HOST2}#g;s#{SOCKET_HOST}#${SOCKET_HOST2}#g' k8s-deployment-template.yml > k8s-deployment-p2.yml"
sh "kubectl apply -f k8s-deployment-p2.yml --namespace=fxtest2 --record --insecure-skip-tls-verify=true --kubeconfig huawei-config"
}
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yupengzheng_admin/blog-site-pc.git
git@gitee.com:yupengzheng_admin/blog-site-pc.git
yupengzheng_admin
blog-site-pc
博客网站PC
master

搜索帮助