Gradle way to perform shell execution and generate artifacts


(Shaun Farrugia) #1

Hey Everyone,

First time using gradle and I’m trying to write a task that zips up a directory on a server. The compressed archive that results would be the output of the artifact creation. I want to run the transformation on the server as well so it would just be ‘tar -czf archive.tgz archive/’

I’m assuming i would use an SSH command to execute this.

What types of gradle configurations would I use for this. Essentially it’s

INPUT: directory of files on a remote server TRANSFORMATION: tar and gzip the directory OUTPUT: gzipped archive file of the directory.

Is there a gradle way of executing on a remote server ? The remote server does not have gradle installed so it would just be a shell. Also would i want to use any of the gradle workflows to support the input/output?


(Andrew Oberstar) #2

Not sure if these are the best solutions for your use case, but here you go…

I’m not aware of any built in way to run a command on a remote server. Any command you can execute on your current server you could execute with an Exec task.

If you were able to access the directory via a share or something, you could use the Tar task to handle this, which would automatically handle inputs and outputs.

If your problem is just that gradle isn’t installed, and you have access to either the internet or a share that you can host the Gradle distribution on, the wrapper is another way to go.


(Shaun Farrugia) #3

Cool thanks Andrew.

I guess the Zip task would be what i want.