2016-11-15 40 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'。 –