Why is my task getting skipped?

Hi,

I’m using Gradle 2.7. I have this environment variable defined …

	Daves-MacBook-Pro-2:myproject davea$ echo $CATALINA_HOME
	/opt/apache-tomcat-6.0.44

And I have this defined in my build.grade file …

	// If $CATALINA_HOME is defined, copy the newly-generated WAR file to the
	// webapps directory
	task deployToTomcat(type: Copy) {
	    from war.outputs
	    into "$System.env.CATALINA_HOME/webapps"
	    onlyIf {
	        System.env['CATALINA_HOME'] != null
	    }
	}

	build.dependsOn deployToTomcat

So I do not understand why this task is getting skipped when I run “gradle build”. Below is the output:

	Daves-MacBook-Pro-2:myproject davea$ gradle build
	Starting a new Gradle Daemon for this build (subsequent builds will be faster).
	:compileJava UP-TO-DATE
	:processResources
	:classes
	:war
	:assemble
	:compileTestJava
	:processTestResources UP-TO-DATE
	:update
	liquibase-plugin: Running the 'main' activity...
	INFO 11/23/15 2:43 PM: liquibase: Successfully acquired change log lock
	INFO 11/23/15 2:43 PM: liquibase: Reading from cbc_db.DATABASECHANGELOG
	INFO 11/23/15 2:43 PM: liquibase: Successfully released change log lock
	Liquibase Update Successful
	liquibase-plugin: Running the 'test' activity...
	INFO 11/23/15 2:43 PM: liquibase: Successfully acquired change log lock
	INFO 11/23/15 2:43 PM: liquibase: Reading from PUBLIC.DATABASECHANGELOG
	INFO 11/23/15 2:43 PM: liquibase: Successfully released change log lock
	Liquibase Update Successful
	:testClasses
	:test
	:check
	:deployToTomcat SKIPPED
	:build

	BUILD SUCCESSFUL

How do I force this task to be executed when the environment variable is defined?