-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webhookURL via credentials #29
Comments
Closing, figured out where I was going wrong. The credential was only bound under the promotions environment and not the build environment which discord notifier is in. |
Re-opening this issue: I've moved over to using pipeline and the discordSend pipeline step. When using this step and "withCredentials", it appears the only way to use the credential for the webhookURL is via groovy string interpolation i.e: discordSend webhookURL: "${discordbuildwebhookurl}", Which results in a warning about insecure usage due to groovy string interpolation being used with a credential. Single quotes however does not work anymore as it looks like the pipeline version of this plugin does not perform env expansion of the webhookURL unlike the WebhookPublisher version which does: DiscordWebhook wh = new DiscordWebhook(env.expand(this.webhookURL)); Is there a reason the expansion is not done? Is there a better way to make use of a credential for the webhookURL that does not involve groovy string interpolation? |
I think env expansion in pipeline step was never brought up, that's why it's not there. I'm also not aware of a better way to use the credential. |
I am new to Jenkins and was trying to resolve the following warning BR, Lars |
the way I went about it was by declaring it in the env {
DISCORD_WEBHOOK_URL = credentials('discord-webhook-url')
}
// ...
discordSend(webhookURL: env.DISCORD_WEBHOOK_URL) |
Is there any way to specify a credential ID in place of the webhookURL string or perhaps a env variable that could be made available via string credential binding?
I tried just entering a variable with the same name as defined in the credential binding plugin (which I used in shell scripts without issue) but the notification fails during build with:
java.net.MalformedURLException: no protocol: ${discordbuildwebhookurl}
Looking at the java file for the plugin, it appears to run env.expand(this.webhookURL) so I assume this is meant to be supported?
The text was updated successfully, but these errors were encountered: