Я пытаюсь отправить расписание для сегодняшнего развертывания, поэтому для этого я пытаюсь сравнить даты, и если дата совпадает, тогда она должна дать «ДА» для строителя строк, а если он не совпадает, то должна отправить «Нет» для строителя строк соответственно. Для этого я написал groovy скрипт для Дженкинса аналогично -
echo "FIT2 Deployment started"
if(runConfig.FIT2Deploy){
FIT2Deploy = sb.append(padToLength('FIT2', 15)).append('|')
}
}
stage('Log Intent') {
echo runConfig.stringify()
}
String makeMarkFor(boolean bool) {
return (bool ? "Yes" : "No")
}
class RunConfig implements Serializable {
String padToLength(String initialValue, int length) {
String tmpVal = initialValue
while (tmpVal.length() < length) {
tmpVal = tmpVal + " "
}
return tmpVal
}
String centerPadToLength(String initialValue, int length) {
String tmpVal = initialValue
boolean atFront = false
while (tmpVal.length() < length) {
if (atFront) {
tmpVal = " " + tmpVal
} else {
tmpVal = tmpVal + " "
}
atFront = !atFront
}
}
String stringify() {
def sb = StringBuilder.newInstance()
sb.append('The following is the schedule for today ').append('|')
sb.append('\n================================\n')
sb.append(padToLength('Environment', 15)).append('|')
sb.append(padToLength(' Deploy', 8))
sb.append('\n--------------------------------\n')
//sb.append(padToLength('FIT2', 15)).append('|')
sb.append(centerPadToLength(makeMarkFor(FIT2Deploy), 8))
sb.toString()
}
}
Но Не работает Может кто-нибудь помочь мне? Я ожидаю выхода - ![enter image description here](https://i.stack.imgur.com/3jwrB.png)