2016-11-15 36 views
0

繼我的標題。詹金斯工作DSL:我想獲得提交或標記分支

我使用groovy來做到這一點。

但它不起作用。誰可以問我怎麼做?

下面是我的源:

job("AAA") { 
parameters { 
    stringParam('branch_name', 'master', 'input branch name') 
    stringParam('commit_id', '123456', 'input commit id') 
} 
gitSCM { 
    userRemoteConfigs { 
    userRemoteConfig { 
    url("ssh://[email protected]/abc.git") 
    name("${branch_name}") 
    } 
    } 
    branches { 
    branchSpec { 
     name("${commit_id}") 
    } 
    }} 

感謝。

回答

0

我們那樣做:

parameters { 
    stringParam('GERRIT_REFSPEC', library.GERRIT_REFSPEC.default, library.GERRIT_REFSPEC.description) 
    stringParam('GERRIT_PATCHSET_REVISION', library.GERRIT_PATCHSET_REVISION.default, library.GERRIT_PATCHSET_REVISION.description) 
} 

scm { 
    git { 
     remote { 
      name('ci-config') 
      url('ssh://url-to-repo') 
      refspec('$GERRIT_REFSPEC') 
     } 

     branch('${GERRIT_PATCHSET_REVISION}') 
    } 
} 

但是手動啓動時,它纔會被使用。由於它是由gerrit觸發的,它設置了使用的值。是你的問題,它被觸發,然後值沒有設置?

+0

To MaTePe。非常感謝。是的,我沒有爲變量設置值。我希望它可以通過手動設置。我認爲'GERRIT_REFSPEC'是'branch_name','GERRIT_PATCHSET_REVISION'是'commit_id'。 –