Re: [go-cd] GOCD Version Upgrade Issue - Windows Agents Failing to Execute 'git pull'

61 views
Skip to first unread message

Sriram Narayanan

unread,
Nov 9, 2023, 11:57:06 PM11/9/23
to go...@googlegroups.com
Looks like the git executable is not on the path for the service account used for the go-agent.

Please compare the PATH settings between your 21.2 and 23.3 instances.

-- Sriram

On Fri, Nov 10, 2023 at 10:55 AM Sri Sai Sruthi JAGANNADDAM <sjagan...@mdsol.com> wrote:
 Could any one please help with this - I am writing to report a challenge we’ve encountered following our recent upgrade from GOCD version 21.2 to version 23.3. During our testing phase, we observed that certain pipelines, which execute on Windows agents, are failing with the following error when run through "Custom Command"
 
 [go] Task: git pull
Took: 0.179s
Exited: 1
'"git pull"' is not recognized as an internal or external command,
operable program or batch file.


This issue seems to be isolated to the Windows agents as the pipelines running on Linux agents are performing without any issues.
The same pipelines were functioning correctly on the previous version of the GOCD server,
which suggests a potential configuration or environment variable path discrepancy in the new version.



The information in this email and any attachments are intended solely for the recipient(s) to whom it is addressed, and may be confidential and/or privileged. Any unauthorized distribution or copying of this transmittal or its attachments is prohibited. If you are not a named recipient or have received this email in error: (i) you should not read, disclose, or copy it, (ii) please notify the sender of your receipt by reply email and delete this email and all attachments.

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/08c6247d-e0c3-4d05-b449-e31c3b899e1dn%40googlegroups.com.

Chad Wilson

unread,
Nov 10, 2023, 1:15:03 AM11/10/23
to go...@googlegroups.com
It's possibly a side effect of fixing issues with spaces in windows commands in GoCD 22.2.0:  https://www.gocd.org/releases.html#22-2-0

It may be that some of your command tasks were *technically* incorrectly configured on earlier versions but worked as a side effect of these bugs in GoCD, and GoCD is now stricter. Or it may be that there is a regression in some circumstances.

Can you please 
- share a screenshot of the UI pipeline task configuration for the 'git pull' example above?
- find that specific task's XML definition inside admin > config XML and share the XML fragment for the task or job (you can redact any sensitive text, I am mainly interested in the 'shape' of the XML)

If my suspicion is correct, a workaround will certainly be possible to correct the task config, but as there are a couple of historical ways tasks could be configured, I'd like to understand what your config looked like before you workaround the problem so I can see if this is avoidable.

-Chad

Sri Sai Sruthi JAGANNADDAM

unread,
Nov 10, 2023, 8:38:25 AM11/10/23
to go-cd
Here is the screenshot 

git pull & mkdir reports 2&gt;nul & IF DEFINED APP_IR_GENERATOR (%APP_IR_GENERATOR%)" are failing as they are not able to recognize git & mkdir, its not a agent issue because the same agent when attached to the gocd server running on 21.2 version it works fine but not working on 23.3 version, as you mentioned custom commands does not allow spaces in the new gocd version, what is best way to handle this, thanks for your inputs
backend code:

<tasks>
              <exec command="git pull">
                <runif status="passed" />
              </exec>
              <fetchartifact artifactOrigin="gocd" srcdir="test" pipeline="" stage="Build" job="defaultJob">
                <runif status="passed" />
              </fetchartifact>
              <exec command="%DEPLOY_SCRIPT%">
                <runif status="passed" />
              </exec>
              <exec command="mkdir reports 2&gt;nul">
                <runif status="passed" />
              </exec>
              <exec command="IF DEFINED APP_IR_GENERATOR (%APP_IR_GENERATOR%)">
                <runif status="passed" />
              </exec>
              <task>

image.png

Sriram Narayanan

unread,
Nov 10, 2023, 11:24:30 AM11/10/23
to go...@googlegroups.com
Move that “pull” into an <arg> like here : 

If you edit this custom command in the UI, then keep only the git in the command, and move the pull into the arguments text area below.

— Sriram

Sriram Narayanan

unread,
Nov 10, 2023, 12:03:59 PM11/10/23
to go...@googlegroups.com
Btw, why exactly are you pulling a git repo? Have you considered adding it as a material to the pipeline?

— Sriram

Sri Sai Sruthi JAGANNADDAM

unread,
Nov 10, 2023, 12:35:14 PM11/10/23
to go-cd
Thanks for the response, its just not git pull, there are also some other commands which we are using.

Sriram Narayanan

unread,
Nov 10, 2023, 1:27:14 PM11/10/23
to go...@googlegroups.com
On Sat, Nov 11, 2023 at 1:35 AM Sri Sai Sruthi JAGANNADDAM <sjagan...@mdsol.com> wrote:
Thanks for the response, its just not git pull, there are also some other commands which we are using.

Indeed. What I'm asking is about only the "git pull".

Actually, you should also consider moving the other commands into a script and then calling just that script.

At a client that I am consulting to, I'm having to deal with about 9000+ custom commands that are across the various pipelines.. I'll be moving the code into scripts and then moving from explicit pipelines to templates.

 

Sri Sai Sruthi JAGANNADDAM

unread,
Nov 10, 2023, 2:14:25 PM11/10/23
to go-cd
git pull worked for me  by adding git has command and pull as argument
mkdir reports 2>nul
IF DEFINED APP_IR_GENERATOR (%APP_IR_GENERATOR%)
how about this if they have spaces,
how we have to handle them custom command
Thanks for your replies .


On Friday, November 10, 2023 at 11:03:59 AM UTC-6 srir...@gmail.com wrote:

Sriram Narayanan

unread,
Nov 10, 2023, 2:19:27 PM11/10/23
to go...@googlegroups.com
Ideally, you should add that git repository as a material and move all the other custom commands into a batch file and then run just that batch file. 

If you are not in a position to add the git repository as a material, then please do move all the remaining custom commands into a batch file and run that.

— Sriram 

Chad Wilson

unread,
Nov 16, 2023, 10:10:08 PM11/16/23
to go...@googlegroups.com
Hi, the screenshot didn't come through correctly, so it would be good if you can include that.

From looking at the XML, If I recall correctly, it might be that you were using the "legacy"/historical syntax for handling exec commands, but need to dig a bit more. With this syntax it is somewhat indeterminate how spaces should be handled. However, I don't think it was intentionally broken by the changes I mentioned in 22.2.0 - although it looks like it might be the case for you. I'd have to validate separately whether you were just using incorrect configuration that happened to work. It should look like this on the UI if you want to do it this way without using a separate script.

image.png
You might want to try editing the command via the UI, and then editing it back in case the syntax needs converting, which will look like:

              <exec command="git">
                <arg>pull</arg>

                <runif status="passed" />
              </exec>

-Chad

Chad Wilson

unread,
Nov 19, 2023, 4:19:35 AM11/19/23
to go...@googlegroups.com
I double-checked this behaviour on GoCD 22.1.0 and can confirm that the commands expressed as your example did work earlier, but unintentionally.

Here's how such a command looks when incorrectly configured:

image.png

image.png

You'll note that the arguments are empty. While this syntax worked "by accident" in GoCD < 22.2.0 it was always incorrect syntax, because the arguments need to be separated from the command. Similar usage for "git pull" never would have worked on Linux or MacOS - that they worked on Windows was a side effect of the way GoCD runs Windows commands (it actually does not execute them directly, and sends them to cmd so that users can use cmd built-ins such as "dir" etc). This side effect meant GoCD did not correctly run tasks with spaces in the path or executable, which was fixed in https://github.com/gocd/gocd/pull/10625

My advice is to fix your command configurations to have arguments properly positioned (as suggested earlier), rather than included in the executable field.

-Chad
Reply all
Reply to author
Forward
0 new messages