I suspect that you'll find that something is misconfigured in your agent 
definition rather than an issue in the checkout step.

I think you'll be able to see that if you:

   1. Create a file in the workspace from inside the Pipeline
   2. Check the permissions of the created file

I suspect you'll see that the permissions are the same as the permissions 
generated by the checkout scm task.

This is the Pipeline script that I used to confirm it:

pipeline {
    agent {
        label '!windows' // sh step not available on windows
    }
    stages {
        stage('Hello') {
            steps {
               writeFile file: 'a-test-file.txt', text: 'Some text inside 
the file'
               sh 'ls -altr a-test-file.txt'
            }
        }
    }
}
On Friday, October 28, 2022 at 5:32:48 AM UTC-6 ice...@googlemail.com wrote:

> In our setup we  run the agents  a separate user via ssh ( contoller: 
> jenkins, agent: jenkinsworker).
>
> In a pipeline we  checkout some code:
> ```
> node(agent) {
>    checkout git+ssh://.....
>   }
> ```
> This  results in the workdir and all git files belonging to the user 
> jenkins,  not jenkinsworker.
>
> Trying to do a commit (with the need to run a commit-msg hook) fails to 
> run the hook unless I explicitly allow the directory as  safe and correct 
> the hook path (it is set to /dev/null if the directory belongs to an other 
> user ).
>
> I would have  expected the workdir to be owned  by the agent user.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/d2943e1e-4caa-47ca-8a30-007d14358107n%40googlegroups.com.

Reply via email to