(项目实战)如何结合k8s和pipeline的流水线,极客时间全套视频

大概就是这么个流程简单来说就是:拉代码—》编译—》打镜像—》推镜像—》部署到 k8s 中,下面的 pipeline 就是在这条主线上进行,根据情况进行增加

pipeline {
	agent { label 'pdc&&jdk8' }
	environment {
		git_addr = "代码仓库地址"
		git_auth = "拉代码时的认证ID"
		pom_dir = "pom文件的目录位置(相对路径)"
		server_name = "服务名"
		namespace_name = "服务所在的命名空间"
		img_domain = "镜像地址"
		img_addr = "${img_domain}/cloudt-safe/${server_name}"
// 		cluster_name = "集群名"
	}
	stages {
		stage('Clear dir') {
			steps {
				deleteDir()
			}
		}
		stage('Pull server code and ops code') {
			parallel {
				stage('Pull server code') {
					steps {
						script {
							checkout(
								[
									$class: 'GitSCM',
									branches: [[name: '${Branch}']],
									userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_addr}"]]
								]
							)
						}
					}
				}
				stage('Pull ops code') {
					steps {
						script {
							checkout(
								[
									$class: 'GitSCM',
									branches: [[name: 'pipeline-0.0.1']], //拉取的构建脚本的分支
									doGenerateSubmoduleConfigurations: false,
									extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'DEPLOYJAVA']], //DEPLOYJAVA: 把代码存放到此目录中
									userRemoteConfigs: [[credentialsId: 'chenf-o', url: '构建脚本的仓库地址']]
								]
							)
						}
					}
				}
			}
		}
		stage('Set Env') {
			steps {
				script {
					date_time = sh(script: "date +%Y%m%d%H%M", returnStdout: true).tr
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值