Hi Jason, Thank you for the email.
I basically do everything as root in the wsl (it's a safe environment :D). I start the server and agent as root (installed gocd as root as well), the script owner is root ect. I double checked these and still if I print "whoami" when the script is executed as a job by gocd the output is 'go'. I have since been able to find a workaround for my root problem so no need for anyone reading this email to spend time on it. It would be nice though to have jobs in gocd on Linux run as root - or a selected user. I find it extremely odd that this is not a query that is quite common (I did a basic search). In any event, gocd is working great! Thank you On Thu, Sep 16, 2021 at 5:04 PM Jason Smyth <[email protected]> wrote: > 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 a topic in the > Google Groups "go-cd" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/go-cd/KzKw8hudN5s/unsubscribe. > To unsubscribe from this group and all its topics, 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 > <https://groups.google.com/d/msgid/go-cd/ae4863bd-ae81-4052-b325-7c34f05bab70n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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/CAAmck7Vfy9Ze4nLrouYP00zC55b6eFsr%2B0QZ%3DML6XerSJNQySw%40mail.gmail.com.
