|  | @@ -1,37 +1,31 @@
 | 
	
		
			
				|  |  | -pipeline {
 | 
	
		
			
				|  |  | -  environment {
 | 
	
		
			
				|  |  | -    registry = "10.2.200.235:50006"
 | 
	
		
			
				|  |  | -    registryCredential = 'localregistry'
 | 
	
		
			
				|  |  | -    dockerImage = ''
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -  agent any
 | 
	
		
			
				|  |  | -  tools {nodejs "node" }
 | 
	
		
			
				|  |  | -  stages {
 | 
	
		
			
				|  |  | -    stage('Cloning Git') {
 | 
	
		
			
				|  |  | -      steps {
 | 
	
		
			
				|  |  | -        git 'http://10.2.200.235:50002/appsptb/ptb-next'
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +node {
 | 
	
		
			
				|  |  | +  try {
 | 
	
		
			
				|  |  | +    stage('Checkout') {
 | 
	
		
			
				|  |  | +      checkout scm
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    stage('Building image') {
 | 
	
		
			
				|  |  | -      steps{
 | 
	
		
			
				|  |  | -        script {
 | 
	
		
			
				|  |  | -          dockerImage = docker.build registry + ":$BUILD_NUMBER"
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +    stage('Initialize'){
 | 
	
		
			
				|  |  | +      def dockerHome = tool 'myDocker'
 | 
	
		
			
				|  |  | +      env.PATH = "${dockerHome}/bin:${env.PATH}"
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    stage('Deploy Image') {
 | 
	
		
			
				|  |  | -      steps{
 | 
	
		
			
				|  |  | -         script {
 | 
	
		
			
				|  |  | -            docker.withRegistry( '', registryCredential ) {
 | 
	
		
			
				|  |  | -            dockerImage.push()
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +    stage('Environment') {
 | 
	
		
			
				|  |  | +      sh 'git --version'
 | 
	
		
			
				|  |  | +      echo "Branch: master"
 | 
	
		
			
				|  |  | +      sh 'docker -v'
 | 
	
		
			
				|  |  | +      sh 'printenv'
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    stage('Build Docker test'){
 | 
	
		
			
				|  |  | +     sh 'docker build -t ptb-fe -f Dockerfile .'
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    stage('Remove Unused docker image') {
 | 
	
		
			
				|  |  | -      steps{
 | 
	
		
			
				|  |  | -        sh "docker rmi $registry:$BUILD_NUMBER"
 | 
	
		
			
				|  |  | +    stage('Deploy'){
 | 
	
		
			
				|  |  | +      if(env.BRANCH_NAME == 'master'){
 | 
	
		
			
				|  |  | +        sh 'docker build -t ptb-fe .'
 | 
	
		
			
				|  |  | +        sh 'docker tag ptb-fe localhost:50006/ptb-fe'
 | 
	
		
			
				|  |  | +        sh 'docker push localhost:50006/ptb-fe'
 | 
	
		
			
				|  |  | +        sh 'docker rmi -f ptb-fe localhost:50006/ptb-fe'
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  catch (err) {
 | 
	
		
			
				|  |  | +    throw err
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  }
 |