Altering a pipeline bat function - where is the definition (Wow, why does he want to do that?)

62 views
Skip to first unread message

Martin Holeček

unread,
Mar 22, 2017, 6:38:29 AM3/22/17
to Jenkins Developers
Hello!

Dear all, please, where can I find the source code of the pipeline 'bat' command?

I would like to make my own function, that would run the bat command as a user ('batas').
I suppose, that there would be some java call to Windows CreateProcess, that can be simply made to call CreateProcessAsUser with every other functionality of pipeline bat remaining the same.

- Why not to run Jenkins service as another user? I dont want to tun the whole script as another user, I need to switch users dynamically .
- Why? Windows SUBST for drives can be altered only locally for a user and I want it to be altered ONLY for one build job to prevent conflicts. (So I will create temporary workspace users for that ("net user ..."))
- Why not to use pstools or powershell? ... That is my current approach, but in the end I love the functionality of pipeline bat (pstools for example cannot process longer arguments than 256 characters) and I suppose that it sould be easily altered...

Thank You very much guys!
Martin

Jesse Glick

unread,
Mar 22, 2017, 2:43:47 PM3/22/17
to Jenkins Dev
On Wed, Mar 22, 2017 at 6:38 AM, Martin Holeček <dart...@gmail.com> wrote:
> Dear all, please, where can I find the source code of the pipeline 'bat'
> command?

`workflow-durable-task-step` + `durable-task` plugins

> I would like to make my own function, that would run the bat command as a
> user ('batas').
> I suppose, that there would be some java call to Windows CreateProcess

Not so easily.

> Why not to use pstools or powershell? ... That is my current approach

Which I would recommend sticking with.

James Nord

unread,
Mar 23, 2017, 12:43:28 AM3/23/17
to Jenkins Developers
Have you tried
bat 'runas /user:foo mycommand'
or
Bat 'psexec user mycommand'

James Nord

unread,
Mar 23, 2017, 12:48:28 AM3/23/17
to Jenkins Developers
Sorry I see you have that working...

Robert Sandell

unread,
Mar 23, 2017, 6:27:42 AM3/23/17
to jenkin...@googlegroups.com
In the era of FreeStyleProjects there was the BuildWrapper.decorateLauncher but I don't know if there is any equivalent operation that can be done for a pipeline step, the documentation states that it won't work. But there is likely some way of switching out the Launcher in the context.

/B

On Thu, Mar 23, 2017 at 5:48 AM, James Nord <james...@gmail.com> wrote:
Sorry I see you have that working...

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/8b3d5dcf-d69a-47da-96c3-fa8f90ddfe41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Martin Holeček

unread,
Mar 23, 2017, 8:41:13 AM3/23/17
to Jenkins Developers
Thank You guys, I will look into `workflow-durable-task-step` + `durable-task` plugins and maybe at decorate launcher :)

(by the way, runas cannot have password specified and psexec sometimes swallows the output)

M.

Jesse Glick

unread,
Mar 23, 2017, 11:41:34 AM3/23/17
to Jenkins Dev
On Thu, Mar 23, 2017 at 8:41 AM, Martin Holeček <dart...@gmail.com> wrote:
> I will look into `workflow-durable-task-step` +
> `durable-task` plugins and maybe at decorate launcher

Again I would strongly advise you use `bat` and whatever command-line
tool Windows normally offers.
Reply all
Reply to author
Forward
0 new messages