Hi Andy, I have never tried running Agents inside WSL (or WSL2) but my guess is that the script will run as whatever account the Go Agent service runs under.
So if you want the script to run as root there are a few options: 1. Run the Go Agent service as root, 2. Grant the "go" user permission to run the script as root via sudo, either with password or without, or 3. Set the script owner to "root" and set the sticky bit so that whenever _anybody_ runs the script it runs as root. (This is probably only viable if the script is a permanent fixture inside the WSL installation. If the script is pulled from elsewhere at runtime then it will be owned by the "go" user and this just moves the problem around, forcing you to find a way to run chown and chmod as root instead of the script itself.) Hope this helps, Jason On Thursday, 16 September 2021 at 07:03:53 UTC-4 Andy Bergh wrote: > > Hi, > > I installed gocd on wsl (not wsl2) on windows server 2019. > > When a job in a stage runs (test.sh for example), the bash file is run as > user 'go'. > Is there a way for me to run the bash file as user root? > > I have been trying to find ways around it but run in so many other > problems. Like ssh keys, access to servers (from within the bash script) > etc. > > This will be much easier if I can somehow make gocd run the bash file as > root in wsl. > > Is this possible? > > Thanks > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/ae4863bd-ae81-4052-b325-7c34f05bab70n%40googlegroups.com.
