0

Following my title.

I use the groovy to do that.

But it doesn't work. who can ask me how do it?

the following is my source:

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

Thanks.

Jarod Ma
  • 21
  • 5

1 Answers1

0

We do it like that:

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}')
    }
}

But it is only used when started manually. Since it is triggered by gerrit, it sets the values that are used. Is that your problem, it is triggered, and then the values are not set?

MaTePe
  • 936
  • 1
  • 6
  • 11
  • To MaTePe. Thanks a lot. Yes, I didn't set value for Variables. I want it could be set by manually. I think the 'GERRIT_REFSPEC' is 'branch_name' and 'GERRIT_PATCHSET_REVISION' is 'commit_id'. – Jarod Ma Nov 16 '16 at 01:34