Files
kouiz/Jenkinsfile

81 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

2025-06-15 23:33:18 +02:00
@Library("cadoles") _
pipeline {
agent {
dockerfile {
label 'docker'
filename 'Dockerfile'
dir 'misc/ci'
}
}
triggers {
2025-06-16 00:07:03 +02:00
cron('0 9 * * 1-5 \n 0 16 * * 1-5')
2025-06-15 23:33:18 +02:00
}
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 {
2025-06-15 23:50:32 +02:00
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: """
2025-06-16 00:07:03 +02:00
@all
2025-06-15 23:51:15 +02:00
2025-06-15 23:50:32 +02:00
${callToAction}
2025-06-15 23:54:49 +02:00
[Répondre à la question du jour](https://kouiz.dev.lookingfora.name/)
2025-06-15 23:50:32 +02:00
""".stripIndent(),
rawMessage: true,
attachements: [
authorIcon: "https://kouiz.dev.lookingfora.name/assets/panda.png",
authorName: "Panda Kouiz"
]
)
}
} else {
2025-06-15 23:54:49 +02:00
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
2025-06-15 23:50:32 +02:00
2025-06-15 23:54:49 +02:00
${leaderboard}
2025-06-15 23:58:28 +02:00
[Voir les scores](https://kouiz.dev.lookingfora.name/quiz/leaderboard)
2025-06-15 23:54:49 +02:00
""".stripIndent(),
rawMessage: true,
attachements: [
authorIcon: "https://kouiz.dev.lookingfora.name/assets/panda.png",
authorName: "Panda Kouiz"
]
)
}
2025-06-15 23:33:18 +02:00
}
}
}
}
}
}