How to ignore a Spock feature method in Grails 3 while running on Jenkins

It is easy to ignore a test only if the test is run in a particular environment thanks to the @IgnoreIf Spock annotation. If you run your tests in Jenkins, it is probable that the tests are being run by a user called jenkins. Thus, you can ignore a test in a Jenkins Job easily:

@Integration(applicationClass = Application.class)
@Rollback
class IntegrationSpec extends Specification {

    @IgnoreIf({ System.getProperty("user.name") == 'jenkins' })
    def "test will be ignored in jenkins"() {
        expect:
        false
    }
}

My next events:
๐Ÿ—“ May 27 09:00 AWS Dublin - Micronaut and AWS Lambda
๐Ÿ—“ Jul 20 09:00 Workshop Security in the Micronaut Framework
๐Ÿ—“ Sep 20 09:00 JCON Online 2022 - Getting Started with the Micronaut Framework
๐Ÿ—“ Sep 23 09:00 JCON Online 2022 - Micronautยฎ Framework and Microstream Java-native persistence engine

Tags: #grails #spock
May 2016, 02.