Gradle Exec task is not executing commands on remote machine

(Rupinder Ghotra) #1
task install_vesper_dependencies_on_load_vms {
    description "Executes Vepper's setup.exe to install C++ redistributable on loadVMs."
    doLast {
        exec {
            workingDir 'cpt-op-01-load1/C$/vesper_cpt'
            standardOutput = new ByteArrayOutputStream()
   "Installing dependencies on $loadVM1..."
            commandLine 'cmd', '/c', "vepper-$vepperVersion-setup.exe", '/S', 'runas', '5'
            ext.output = {standardOutput.toString() }


It gives me error that Exec does not support UNC paths. If this is the case could any one please redirect me how can I run commands on remote machine using Gradle.

(Benjamin Muschko) #2

It would be fairly easy to run SSH command via Gradle against a Linux machine with the help of the SSH plugin. Is your remote machine a Windows box?

(Schalk Cronjé) #3

If it’s Windows then use can use groowin. It does not have a specific Gradle plugin, but if you put it on the buildscript classpath, you can create a custom task to run it.

(Rupinder Ghotra) #4

Yes, its windows machine.

(Rupinder Ghotra) #5

I have checked groowin and it seems really cool. I have tried adding the following block into my build script. Though it is able to download dependencies from Maven but giving me the following error:

unable to resolve class com.aestasit.winrm.DefaultWinRM
import static com.aestasit.winrm.DefaultWinRM.*


import static com.aestasit.winrm.DefaultWinRM.*
buildscript {
    repositories {
    dependencies {
        classpath group: 'com.aestasit.infrastructure.groowin', name: 'groowin', version: '0.1.8'

Could you please what I am doing wrong here?

(Rupinder Ghotra) #6

Found the problem the import path should be:

import static com.aestasit.infrastructure.winrm.DefaultWinRM.*

and not import static com.aestasit.winrm.DefaultWinRM.*

I will request them to update README according to the new import. Now, I am going to try groowin to see if it works for me. I will keep you posted. Thanks

(Rupinder Ghotra) #7

@Schalk_Cronje Schalk_Cronje, I have tried integrating groowin into my buildscript. It works and tried to connect to port 5985 by default. But on this port the machine is not listening.Then, I overrided port to 4445 on which the machine is listening. Now, it establishes the connection that I can see. But my build get stuck after connecting and does not execute any command. I have attached a picture showing my code snippet and my build status. Could you please suggest something?

task install_vesper_dependencies_on_load_vms << { "Running Vesper on remote machine..."
    remoteManagement {
        host = 'cpt-op-01-load1'
        user = 'CPT-OP\\admin'
        password = 'password'
        exec 'del', 'C:\\Temp\\temp.txt'

(Schalk Cronjé) #8

I have asked the person who wrote groowin if you can help with this. I am not sure when he’ll respond.

(Rupinder Ghotra) #9

Thanks, I will wait for his response.

(Schalk Cronjé) #10

You can always leave an issue on Github as well. (I know Andrey is at GreachConf atm, so not sure when he will look at it).

(Rupinder Ghotra) #11

I will do that too. Alot of my work would be dependent on whether I would be able to leverage Groowin or not. Otherwise, i will have to fall back to powershell files and that would be not a very clean solution. Will keep you posted. Thanks

(Andrey Adamovich) #12


Groowin actually has a Gradle plugin:

Also, there is a Packer project to create VM box against which we tested WinRM implementation in Groowin: You can find some Windows configuration details in there.

Can you also run your gradle build with -D option and share the output?

Best regards,

(Rupinder Ghotra) #13

Hi @Andrey_Adamovich
Thank you for your response, I had followed your suggestion but still no success. Here what I did:

  1. This time I used groowin plugin for Gradle
  2. Configured winrm in remote machine for using HTTP for communication(please find attached screen shot of winrmConfigurations). Followed this link:
  3. Executed build file but it is throwing exception. Though, this time it is not stuck like the last time but it is failing. I am getting the following error:

NEGOTIATE authentication error: Invalid name provided (Mechanism level: KrbExcep tion: Cannot locate default realm) KERBEROS authentication error: Invalid name provided (Mechanism level: KrbExcept ion: Cannot locate default realm) An error details: 401 :

4: Attached files: build code, winrmConfig(for remote machine), build_output(–stacktrace and --info), build_output( (77.9 KB))

Please suggest what I am doing wrong here.

(Andrey Adamovich) #14

What if you specify user name without domain?

(Andrey Adamovich) #15

Are you using HTTP proxy in your system or Gradle settings?

(Milind Joshi) #16

Is this issue resolved? I have tried similar code as @rsghotra89 and facing 401 issue.
The documentation is also not clear.

(Milind Joshi) #17

I got the ball rolling somehow.
The authentication error is due to the winrm service has “Kerberose” and “Negotiate” in auth section.
Basic = true
Kerberos = true
Negotiate = true [Source=“GPO”]
Certificate = false
CredSSP = false
CbtHardeningLevel = Relaxed

By default, it selects the Kerberos mode. So when disabling the Kerberose, it was still producing auth error(401).
NEGOTIATE authentication error: No valid credentials provided (Mechanism level
No valid credentials provided (Mechanism level: Failed to find any Kerberos tg
NEGOTIATE authentication error: No valid credentials provided (Mechanism level
No valid credentials provided (Mechanism level: Failed to find any Kerberos tg
Then if the Kerberose is set to false, it tries Negotiate mode. When i disabled both (by setting them as false), I was able to execute the commands by exec. But disabling Kerberose has its own disadvantages.

My concern iis, the documentation is not briefly provided for this. We don;t know what additional parameters are supported in remoteManagement.

Posting the reference link in case someone faces similar issue: