magnayn / Hudson-GIT-plugin

Git plugin for Hudson
http://wiki.hudson-ci.org/display/HUDSON/Git+Plugin
51 stars 26 forks source link

Escaping dollar sign from refspec #27

Closed khanhldt closed 2 years ago

khanhldt commented 2 years ago

Description

I got a problem using this plugin with refspec not escaping the dollar sign (dollar sign is a valid character for naming git branch). See log below

09:49:28  hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress --depth=1 -- git@github.com:lyft/LYFT-REPO.git +refs/heads/use-install-go-from-$PATH:refs/remotes/origin/use-install-go-from-$PATH" returned status code 128:
09:49:28  stdout: 
09:49:28  stderr: fatal: invalid refspec '+refs/heads/use-install-go-from-/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:refs/remotes/origin/use-install-go-from-/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

The command I ran is something along the lines of

checkout scm: [
                  $class: 'GitSCM',
                  branches: branches,
                  extensions: [
                    [$class: 'GitLFSPull'],
                    clone_option,
                    [$class: 'RelativeTargetDirectory', relativeTargetDir: 'target']
                  ],
                  userRemoteConfigs: [[
                    credentialsId: 'ssh-key',
                    url: "git@${github_url}:${repo_full_name}.git",
                    refspec: "${refspec}"
                  ]]

What did I try

I tried to escape the value before passing into the call (e.g. refspec.replace('$', '\$')), but that didn't help regardless of how many backslashes I used.

khanhldt commented 2 years ago

Well, I realized that I should have filed this with Jenkins instead. Closing for now.