My decelerative pipeline has a stage that sends out a message to a Discord Channel using a webhook. The script in my Jenkins file that does this is as follows.
stage('DiscordMessage') {
steps {
discordSend {
webhookURL: "https://discord.com/api/webhooks/123456789012345678/me-3_LacrufNcvKg-U",
discordSend description: 'Status of my Project',
footer: '',
image: '',
link: env.BUILD_URL,
result: currentBuild.currentResult,
scmWebUrl: '',
thumbnail: '',
title: JOB_NAME
}
}
}
The jenkinsfile is checked into SCM on GIT. When I run the job on Jenkns the SCM checkout is performed successfully. However it throws compilation errors.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 101: unexpected token: https://discord.com/api/webhooks/123456789012345678/me-3_LacrufNcvKg-U @ line 101, column 27.
webhookURL: "https://discord.com/api/webhooks/123456789012345678/me-3_LacrufNcvKg-U",
This script was generated using the Jenkins Snippet Generator. The generator had the Webhook as the last parameter. With this Jenkins would throw the following compilation error
Missing required parameter: "webhookURL" @ line 100, column 13.
discordSend {
^
So I made a few changes based on example provided on the Jenkins Discord Notifier Plugins Page https://plugins.jenkins.io/discord-notifier/. I changed Single quotes to double quotes, moved the webhook URL as the first parameter etc. I still get the compliation error. Any idea what could be wrong.
Parentheses ()
and curly braces {}
are not freely interchangeable in Groovy :). It's:
discordSend(
webhookURL: "https://discord.com/api/webhooks/123456789012345678/me-3_LacrufNcvKg-U",
discordSend description: 'Status of my Project',
footer: '',
image: '',
link: env.BUILD_URL,
result: currentBuild.currentResult,
scmWebUrl: '',
thumbnail: '',
title: JOB_NAME
)