@Library("cadoles") _ pipeline { agent { dockerfile { label 'docker' filename 'Dockerfile' dir 'misc/ci' } } triggers { cron('0 9 * * 1-5 \n 0 16 * * 1-5') } parameters { booleanParam(name: 'FORCE_SEND', defaultValue: false, description: 'Force send of message') } stages { stage("Send call to action") { when { allOf { anyOf { triggeredBy 'TimerTrigger' expression { params.FORCE_SEND == true } } } } steps { script { def currentTime = new Date() def hour = currentTime.hours def isMorning = hour < 12 if (isMorning) { String callToAction = sh(script: "curl https://kouiz.dev.lookingfora.name/api/presentation/turn", returnStdout: true) if (callToAction) { rocketSend( avatar: "https://kouiz.dev.lookingfora.name/assets/panda.png", channel: '#le-kouiz', message: """ @all ${callToAction} [Répondre à la question du jour](https://kouiz.dev.lookingfora.name/) """.stripIndent(), rawMessage: true, attachements: [ authorIcon: "https://kouiz.dev.lookingfora.name/assets/panda.png", authorName: "Panda Kouiz" ] ) } } else { String leaderboard = sh(script: "curl https://kouiz.dev.lookingfora.name/api/presentation/leaderboard", returnStdout: true) if (leaderboard) { rocketSend( avatar: "https://kouiz.dev.lookingfora.name/assets/panda.png", channel: '#le-kouiz', message: """ @here ${leaderboard} [Voir les scores](https://kouiz.dev.lookingfora.name/quiz/leaderboard) """.stripIndent(), rawMessage: true, attachements: [ authorIcon: "https://kouiz.dev.lookingfora.name/assets/panda.png", authorName: "Panda Kouiz" ] ) } } } } } } }