-
Bug
-
Resolution: Won't Fix
-
Major
-
Jenkins 2.332.3 and Jenkins 2.414.3
git plugin version: 5.2.1 and 4.11.1
When I ran a shell script through pipeline job today, I found that the Git_Branch parameter value I got from the bash script was different from the Git_Branch value I passed in when I triggered the job.
After analysis and debugging, I found that the git plugin tampered with the value of the job parameter Git_Branch. And I found that freestyle job had similar issue.
The phenomenon is as follows:
When I use b1234567 to trigger the pipeline job, the value the Git_Branch shell script gets is the branch information used by the git plug-in.
When I trigger freestyle job in the same way, the Git_Branch value is overwritten when the git plug-in is used.
The Git_Branch value is correctly get when the git plug-in is not used
I can't duplicate the exact failure that you're reporting, but I can guide you that it is not a good choice to define a job parameter that is one of the environment variables that the git plugin sets as part of its operations. Those environment variables are set for the convenience of Jenkins jobs. Using them as a parameter risks that your parameter value will be ignored or the git plugin behavior will be unexpectedly changed.
It is also not a good choice to use parameter names that differ from the git plugin environment variables names only by the case of the variable name. Windows treats the names of environment variables as case insensitive. With Windows command prompt, I see the following
This behavior of the git plugin won't be changed. Choose a name for the parameter that is not one of the environment variables set by the git plugin and does not differ from those variables only by the case of the environment variable name.