kuleuven / jenkins-mattermost-plugin

Jenkins plugin for Mattermost
MIT License
24 stars 46 forks source link

Add multiple plugins to one job #15

Closed IchHabRecht closed 7 years ago

IchHabRecht commented 7 years ago

I would like to configure different notification settings for different channels. If I add multiple mattermost post-build actions to one jobs it seems only the last one is executed. Is there any way to add one plugin for all notifications and one for only failed ones?

jovandeginste commented 7 years ago

I'm not sure this is the answer you are looking for, but since a few months I'm using Jenkinsfiles. This lets me combine any (supported) plugins programmatically. This means I can send any Mattermost notification at any stage of the job, exactly the way I want it (as a user).

If you never heard of Jenkinsfiles or the Jenkins workflow/pipelines plugins, I honestly suggest you check it out!

If there is anything holding you back from using it, I'm sorry this solution is not what you need. It may be opportune to reevaluate?

IchHabRecht commented 7 years ago

Due to our project infrastructure I'm not able to use Jenkinsfiles. And I'm not sure this solves my problem. I'm already able to use the plugin in my pipeline where I need it. The problem is I cannot add more than one plugin to that job. Only the last plugin is executed, not the other one(s) defined.

jovandeginste commented 7 years ago

Jenkinsfiles should fix your problem, as you write code to define when you send what message (even multiple times with different parameters). That is, if I understand your problem correctly, you could write something like this near the end of the Jenkinsfile:

// Send Mattermost notifications:
mattermostSend message: 'Job XYZ finished', channel: '#all-jobs', endpoint: 'https://url/hooks/token'
if (currentBuild.result == 'FAILURE') {
    mattermostSend message: 'Job XYZ failed', channel: '#failed-jobs', endpoint: 'https://url/hooks/token', color: 'danger'
}
if (currentBuild.result == 'ABORTED') {
    mattermostSend message: 'Job XYZ aborted', channel: '#aborted-jobs', endpoint: 'https://url/hooks/token', color: 'warning'
}

That being said, if you can't use Jenkinsfiles, it's a moot point... Can you clarify what you mean by "add more than one plugin"; I can only add the Mattermost post-build task once, so you actually mean different plugins. So do you mean only one of the (different) post-build tasks are executed??

IchHabRecht commented 7 years ago

Can you clarify what you mean by "add more than one plugin"; I can only add the Mattermost post-build task once, so you actually mean different plugins.

This might explain my problem. I'm working with the config.xml files and (normally) not the web interface. I added a second plugin in the configuration (with is displayed in the web interface as well) and didn't noticed this plugin can only be added once to the post-build actions. Is there any reason for this limitation?

jovandeginste commented 7 years ago

I was not aware of post-build actions that can be added multiple times to a job (using the web ui -- I try to stay away from xml ...) Do you have an example of such a plugin?

IchHabRecht commented 7 years ago

I see, seems like post-build actions can only be used ones.