Нет доступа к глобальной переменной @Field - PullRequest
2 голосов
/ 03 августа 2020

У меня есть эта глобальная переменная внутри моего Groovy скрипта

@Field ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneId.of("UTC"))

@Field DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")

Но я не могу получить к ней доступ внутри класса в моем скрипте: (

class SmsMessageDeliveryPartResult {
    String dateSent
    String dateDeliveryReceiptReceived

    DeliveryResult() {
        this.dateSent = currentDateTime.format(formatter)
        this.dateDeliveryReceiptReceived = currentDateTime.format(formatter)
    }
}

I получить эту ошибку:

Caught: groovy.lang.MissingPropertyException: No such property: currentDateTime for class:
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...