Gradle build works from command line but not from jenkins

Hi, I am new to gradle and jenkins. I have below script(Gradle 3.4.1) running in my windows machine to test the commandline. It works fine when I run it from gradle commandline. But when I try to run from Jenkins it runs without error but doesn’t create a folder. Same is the case for all the the commands. Please help me.

Code:

task mdir(type:Exec) {

workingDir 'C:\\temp'

commandLine 'cmd.exe', '/c', 'mkdir', 'temp1', 
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()

}

println commandLine

}

Edit: I am running Jenkins on webserver (Tomcat) not as a windows service. Is it causing the issue? I see that ant script runs fine.

Why not just use Project.mkdir()?

Thanks for your response!
I actually want to run other command namely “mqsicreatebar” even that is not working. Exploring how to use commandline in Gradle-Jenkins.