您的位置:首页 > 文旅 > 旅游 > 营销方案英文_推广策略英语_项目外包平台_产品推广策划方案怎么做

营销方案英文_推广策略英语_项目外包平台_产品推广策划方案怎么做

2024/12/23 17:04:00 来源:https://blog.csdn.net/u011533425/article/details/142595383  浏览:    关键词:营销方案英文_推广策略英语_项目外包平台_产品推广策划方案怎么做
营销方案英文_推广策略英语_项目外包平台_产品推广策划方案怎么做

实现代码打包编译
容器镜像构建
jenkins编译采用docker构建。
遇到问题:
1.需要限制docker 容器的内存和cpu
docker {
image ‘ccr.ccs.tencentyun.com/libary/maven:3.6.3-jdk-8’
args “-v ${WORKSPACE}:/workspace --memory=‘2048m’ --cpus=‘1’”
}
2.jenkins构建需要限制构建时间。避免job任务构建时间太长
timeout(time: 30, unit: ‘MINUTES’) { //限制30分钟的构建时间。超过30分钟自动断开

pipeline {agent anyparameters {choice(name: 'GIT_BUILD_REF',choices: ['test', 'master'],description: 'Select the Git branch or commit to build')}environment {GIT_REPO_URL = "http://192.168.1.2/djb/djb-cloud.git"HARBOR_REGISTRY = "192.168.2.1:5000"HARBOR_HOST= "example.com"DOCKER_BUILD_CONTEXT = './module-system/djb-module-system-biz'CODING_DOCKER_IMAGE_NAME = 'ops/djb-module-system'DOCKERFILE_PATH = './module-system/djb-module-system-biz/Dockerfile'HARBOR_CREDENTIALS_ID = "fd3362aa-xx"   //凭据idCREDENTIALS_ID = "0ee6d913-xxx"DEPLOYMENT_NAME = "djb-module-system-deploy"CONTAINER_NAME = "djb-module-system-deploy"WEBHOOK_URL ="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxx123"}stages {stage('检出') {steps {checkout([$class: 'GitSCM',branches: [[name: "${params.GIT_BUILD_REF}"]],userRemoteConfigs: [[url:  "${env.GIT_REPO_URL}",credentialsId: "${env.CREDENTIALS_ID}"]]])script {// 获取当前的Git提交IDenv.GIT_COMMIT_ID = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()// 获取当前时间env.CURRENT_TIME = sh(script: 'date +%Y%m%d%H%M%S', returnStdout: true).trim()// 生成版本号env.DOCKER_IMAGE_VERSION = "${params.GIT_BUILD_REF}-${env.GIT_COMMIT_ID}-${env.CURRENT_TIME}"}	}}stage('build') {agent {docker {image 'ccr.ccs.tencentyun.com/libary/maven:3.6.3-jdk-8'args "-v ${WORKSPACE}:/workspace   --memory='2048m' --cpus='1'"}}steps {script {timeout(time: 30, unit: 'MINUTES') {sh "cd /workspace && ls -l"sh 'pwd'sh "ls -l && mvn -v"sh 'cd /workspace && pwd && mvn clean package -Dmaven.test.skip=true'}}     }}stage('构建镜像并推送到 Harbor Docker 制品库') {steps {script {// 使用 withRegistry 来处理 HTTP 登录docker.withRegistry("https://${env.HARBOR_REGISTRY}", "${env.HARBOR_CREDENTIALS_ID}") {def dockerImage = docker.build("${env.CODING_DOCKER_IMAGE_NAME}:${env.DOCKER_IMAGE_VERSION}", "-f ${env.DOCKERFILE_PATH} ${env.DOCKER_BUILD_CONTEXT}")dockerImage.push()env.IMAGE_NAME = "${env.HARBOR_HOST}/${env.CODING_DOCKER_IMAGE_NAME}:${env.DOCKER_IMAGE_VERSION}"	}}}}stage('部署到 Kubernetes') {when {expression { return params.GIT_BUILD_REF == 'test' }}steps {script {// 使用 withKubeConfig 来处理 Kubernetes 配置withKubeConfig(credentialsId: 'tke-cluster-credentials') {sh "kubectl set image deployment/${env.DEPLOYMENT_NAME} ${env.CONTAINER_NAME}=${env.IMAGE_NAME} --record"}}}}}post {success {script {def message = """{"msgtype": "text","text": {"content": "Jenkins 部署成功!\\n部署镜像号: ${env.IMAGE_NAME}\\n部署状态:\\n${env.DEPLOYMENT_NAME}:成功"}}"""sh """curl -X POST ${WEBHOOK_URL} \-H 'Content-Type: application/json' \-d '${message}'"""}}failure {script {def message = """{"msgtype": "text","text": {"content": "Jenkins 部署失败!\\n部署镜像号: ${env.IMAGE_NAME}\\n部署状态:\\n${env.DEPLOYMENT_NAME}:失败"}}"""sh """curl -X POST ${WEBHOOK_URL} \-H 'Content-Type: application/json' \-d '${message}'"""}}}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com