jenkins 流水线

pipeline { 
	playbox any
	environment {
		projectname = 'dev-xman'
		appname='xman-playbox'
		result='xman-playbox'
		version='v1.0'
	}
	stages{
		stage('获取代码') {
			steps{
				sh '''
				cd /home/tomcat/.jenkins/workspace/
				rm -rf $/home/tomcat/.jenkins/workspace/*
				if [ ! -d $appname ]; then 
					mkdir $appname 
				fi
				'''
				dir('/home/tomcat/.jenkins/workspace/xman-playbox'){
					git branch: "master", credentialsId: '76882b93-5854-44f1-b109-0d7e8c1d2f13', url: 'http://xxxx.com/xman-playbox.git'
				}
			}
		}
		stage('代码编译') {
			steps{
			    sh '''
			    cd /home/tomcat/.jenkins/workspace/xman-playbox
			    ls
				'''
			}
		}
		stage('制作镜像') {
		    steps {
			script {
				withDockerRegistry(credentialsId: '2a69663f-31cb-4c1c-99a9-c42437cbbf90',url:'https://registry.xxxx.com') {
					def customImage = docker.build("registry.xxxx.com/dev-xman/${appname}:${version}","/home/tomcat/.jenkins/workspace/xman-playbox/")
					customImage.push()
				}
			} 

		      }
		}
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *