github.com/kubesphere/s2irun@v3.2.1+incompatible/Jenkinsfile (about)

     1  
     2  pipeline {
     3      agent {
     4          node {
     5              label 'go'
     6          }
     7      }
     8  
     9      parameters {
    10        string(name:'TAG_NAME',defaultValue: 'latest',description:'')
    11      }
    12  
    13      environment {
    14        IMAGE_NAME = 'kubespheredev/s2irun'
    15      }
    16  
    17      stages {
    18  
    19          stage ('checkout scm') {
    20              steps {
    21                  checkout(scm)
    22              }
    23          }
    24  
    25          stage ('unit test'){
    26              steps{
    27                  container ('go') {
    28  
    29                      sh '''
    30  mkdir -p /home/jenkins/go/src/github.com/kubesphere
    31  ln -s `pwd` /home/jenkins/go/src/github.com/kubesphere/s2irun
    32  cd /home/jenkins/go/src/github.com/kubesphere/s2irun
    33  make test'''
    34                  }
    35              }
    36          }
    37  
    38          stage ('docker push') {
    39              when{
    40                  branch 'master'
    41              }
    42  
    43              steps {
    44                  container ('go') {
    45                      sh "docker build . -t $IMAGE_NAME:$TAG_NAME"
    46                      withCredentials([usernamePassword(passwordVariable : 'DOCKER_PASSWORD' ,usernameVariable : 'DOCKER_USERNAME' ,credentialsId : "dockerhub-id" ,)]) {
    47                          sh 'echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin'
    48                          sh 'docker push $IMAGE_NAME:$TAG_NAME'
    49                      }
    50                  }
    51              }
    52          }
    53      }
    54  
    55  
    56  }