I am using a fairly old version of the plugin (1.20) and updating is not up to me. I'm having trouble setting the name of the repository for my Github repository. Here is my scm block:
scm {
git ("http://my-github/my-org/${Repository}.git", "*/${Branch}") { node ->
def remoteConfig = node/userRemoteConfigs/'hudson.plugins.git.UserRemoteConfig'
remoteConfig << refspec("+refs/heads/${Branch}:refs/remotes/origin/${Branch}")
remoteConfig << name("origin")
node / localBranch << "${Branch}"
}
}With the name("origin") line, not only do I not get the result I want, but the name of the job is overridden to be "origin" as well. If I leave off the name("origin") line, the refspec DOES get generated correctly. The URL does not!It looks to me in the XML like the name and refspec should be added in the same way.
Here is the resulting XML from the config above:
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<ignoreNotifyCommit>false</ignoreNotifyCommit>
<gitTool>Default</gitTool>
<skipTag>false</skipTag>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>origin</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<localBranch>master</localBranch>
</scm>Here is the XML when I leave off the name("origin"):
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<ignoreNotifyCommit>false</ignoreNotifyCommit>
<gitTool>Default</gitTool>
<skipTag>false</skipTag>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>http://my-github/my-org/my-repo.git</url>
<refspec>+refs/heads/master:refs/remotes/origin/master</refspec>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<localBranch>master</localBranch>
</scm>Here is how I *want* it to look, taken from a job I manually configured.
<scm class="hudson.plugins.git.GitSCM" plugin="g...@1.1.22-SNAPSHOT">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/master:refs/remotes/origin/master</refspec>
<url>http://my-github/my-org/my-repo.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>origin/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<localBranch>master</localBranch>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<ignoreNotifyCommit>false</ignoreNotifyCommit>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir/>
<reference/>
<excludedRegions/>
<excludedUsers/>
<gitConfigName/>
<gitConfigEmail/>
<skipTag>false</skipTag>
<includedRegions/>
<scmName/>
</scm>I unset the <name> in an existing job and noticed that there was then a <name/> element. This leads me to believe that I should be overwriting, rather than appending, but I can't actually find the right syntax to do that. If I zero out the refspec, there is an empty <refspec/>, rather than it just not being there either. Hmm.