pipeline {
  agent {
    docker {
      image 'node:lts'
      args '-v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /usr/bin/sshpass:/usr/bin/sshpass'
    }

  }
  stages {
     stage('PUSH IMAGE') {
       steps {
         sh '''docker login --username=rcsadmin@gsst -p 9HRpm_hk registry.cn-shenzhen.aliyuncs.com
         docker pull $get_image_address/$image_name:latest
         docker tag $get_image_address/$image_name:latest $registry_address/$image_name:latest
         docker push $registry_address/$image_name:latest'''
       }
     }
    stage('Cleanup') {
      steps {
        cleanWs(deleteDirs: true)
      }
    }
   }
  environment {
    registry_address = 'registry.cn-shenzhen.aliyuncs.com/gsst'
    get_image_address = 'nexus3.gsstcloud.com:8092/poc'
    image_name = 'poc-api'
  }
}
