unity容器监听
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.3 KiB

2 years ago
def buildService(serverName){
docker.withRegistry('https://registry.internal.jumaiyx.cn', 'docker-registry-internal-backend') {
def img = docker.build("jm/$serverName:${env.BUILD_ID}",".")
img.push()
}
}
pipeline {
agent any
environment {
// 服务名
2 years ago
SERVER_NAME = 'room-hot-compute-job'
2 years ago
// 镜像名称,对应K8S_FILE里面Deployment.containers的name
2 years ago
IMAGE_NAME = 'room-hot-compute-job'
2 years ago
// git路径
GIT_URL = 'http://git.gz.internal.jumaiyx.cn/job/room-server-clear.git'
// 分支
GIT_BRANCH = '*/master'
// kubectl执行文件
2 years ago
K8S_FILE = 'job.yaml'
2 years ago
// k8s deployment名称,对应K8S_FILE里面Deployment的name
2 years ago
K8S_DEPLOYMENT = 'room-hot-compute-job'
2 years ago
}
stages {
stage('git代码拉取') {
steps {
checkout([$class: 'GitSCM', branches: [[name: "${env.GIT_BRANCH}"]], extensions: [], userRemoteConfigs: [[url: "${env.GIT_URL}"]]])
echo 'git代码拉取 成功'
}
}
stage('docker镜像打包') {
steps {
echo "镜像版本:${env.BUILD_ID}"
buildService("${env.SERVER_NAME}")
echo 'docker镜像打包'
}
}
stage('传入k8s-master') {
steps {
2 years ago
sshPublisher(publishers: [sshPublisherDesc(configName: 'k8s', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: "${env.K8S_FILE}")], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
2 years ago
echo '将yaml传入k8s-master'
}
}
stage('部署服务') {
steps {
2 years ago
sh "ssh root@192.168.1.156 kubectl apply -f /usr/local/k8s/${env.K8S_FILE}"
2 years ago
echo '部署服务'
//sh '''if if (( ${env.BUILD_ID} == 1 ))
//then
// ssh root@192.168.1.156 kubectl apply -f /usr/local/k8s/${env.K8S_FILE}
// echo '部署服务'
//fi'''
}
}
}
}