2017-08-26 60 views

回答

1

我可以拿出最好的。

stage('Stage Checkout') { 
     checkout([ 
      $class       : 'GitSCM', 
      branches       : scm.branches, 
      doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations, 
      extensions      : [] + [ 
       $class  : 'LocalBranch' 
      ], 
      userRemoteConfigs    : scm.userRemoteConfigs, 
     ]) 
    } 

    //do git stuff 

    stage('Push Version Back to Git') { 
     withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'jenkins', usernameVariable: 'GIT_AUTHOR_NAME', passwordVariable: 'GIT_PASSWORD']]) { 
      sh 'echo ${GIT_AUTHOR_NAME} pushing ' 
      sh 'git config --global user.email "[email protected]"' 
      sh 'git config --global user.name "Jenkins"' 
      sh 'git config --global push.default simple' 
      sh('git push https://${GIT_AUTHOR_NAME}:${GIT_PASSWORD}@github.com/a/a.git') 
     } 
    } 
相關問題