0

I'm using this plugin for my Gradle: https://gradle-ssh-plugin.github.io/

I've added a new task called delete which is supposed to delete certain folders and files. So I wrote the following:

task delete {
    ssh.run {
        session(remotes.web01) {
            execute 'cd /var/www/html/; rm -rf *'
        }
    }
}

But this wouldn't do anything. When I execute ./gradlew delete, it will just say

:delete UP-TO-DATE

BUILD SUCCESSFUL

Total time: 4.367 sec

I can't seem to figure out why my folders and files are not being deleted. Just to make sure my session run was okay, I ran execute 'cd /var/www/html/; mkdir test' instead of what I originally had and it did create a folder called "test". And after putting some files in there, when I replaced the execute command with execute 'cd /var/www/html/; rm -rf test', it did delete the folder properly.

I made sure that all the folders and files' are both readable and writable.

Any idea what I'm supposed to do?

sparkhee93
  • 1,381
  • 3
  • 21
  • 30

1 Answers1

0

You're executing the ssh actions during the configuration phase rather than the execution phase. The task should be defined as

task delete << {
    ssh.run {
        session(remotes.web01) {
            execute 'cd /var/www/html/; rm -rf *'
        }
    }
}
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255