栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Jenkins流水线脚本

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Jenkins流水线脚本

脚本一
def git_address = "http://gitlab.rb.com/qwer/tegent.git"
def git_auth = "cf922df0-38c4-46b4-a556-fa0604138e20"
//构建版本的名称
def tag = "latest"
//Harbor私服地址
def harbor_url = "harbor.od.com"
//Harbor的项目名称
def harbor_project_name = "tensquare"
//Harbor的凭证
def harbor_auth = "bbcb94c0-8f1d-4214-bd3c-76edf52cd244"
//k8s的凭证
def k8s_auth = "1d425ea5-f25a-44c1-bfde-e9bcd311a8b8"
//定义k8s-harbor的凭证
def secret_name = "kubernetes-admin-token-d5snf"
def file = "tegent-file"
def system = "tegent-system"
def file_with_module = "tegent-modules-file"
def system_with_module = "tegent-modules-system"
def parent = "tegent-modules"
def api = "tegent-api"
def common = "tegent-common"
//pod模板
podTemplate(label: 'jenkins-slave', cloud: 'kubernetes', containers: [
	containerTemplate(
		name: 'jnlp',
		image: "harbor.od.com/public/jenkin-with-maven:v3.6.2"
	),
	containerTemplate(
		name: 'docker',
		image: "docker:stable",
		ttyEnabled: true,
		command: 'cat'
	),
],
volumes: [
	hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
	nfsVolume(mountPath: '/usr/local/apache-maven/repo', serverAddress: '192.168.0.153' , serverPath: '/opt/nfs/maven'),
],
)
{
node("jenkins-slave"){
// 第一步
	stage('拉取代码'){
		checkout([$class: 'GitSCM', branches: [[name: '${branch}']],
		userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_address}"]]])
	}
	// 第二步
	stage('代码编译'){
		sh "mvn clean install -pl ${common} -am -Dmaven.test.skip=true -Ddockerfile.skip"
	}
	// 第三步
	stage('构建镜像,部署项目'){
		//把选择的项目信息转为数组
		def selectedProjects = "${project_name}".split(',')
		def home = "$PWD"
		def destination = 'src/main/resources'
		def docker_file_home = ''
		def login_num = '1'
		for(int i=0;i
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/658581.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号