Looking for documentation on HTTP Request variables

Hello, I looked through the README.md file for this plugin and doesn’t look like there’s any insight on if and how you can send variables as a response body. For my use case, I want to send the project and build number to Mattermost. There is a Mattermost plugin already, but it seems as though I keep coming up to a “Failure” error and it’s not very helpful because that’s all it sends back.

I looked into using HTTP request plugin and that actually does seem to be sending notifications to my Mattermost channel. The issue is I don’t know if the HTTP request plugin supports passing in variables from either Jenkins or environment variables.

I want to send a notification to my Mattermost channel using something like this.

Build Successful: ${env.JOB_NAME} - Build #${env.BUILD_NUMBER}


Build Failed: ${env.JOB_NAME} - Build #${env.BUILD_NUMBER} 
body = "Build Successful: ${env.JOB_NAME} - Build #${env.BUILD_NUMBER}"
http_request body: body, ...

I’m not trying to create a pipeline job like that though. I’m using Fresstyle and I have other things I want the project to do when the build has been successful for instance send email notifications, run an archive process, etc. Sending notifications to my Mattermost channel is one of them as well as storing the code in a local workspace on my Jenkins server.

Hello? I’m still looking for a solution. Haven’t been able to get anything so far.

I can’t imagine anyone here has experience with that plugin outisde of pipeline. If the plugin doesn’t work for you, i recommend doing something with shell + curl, since you got full access to all variables in shell blocks in freestyle.

It just really sucks because the Mattermost plug-in that’s available was very promising since it sends notifications based on a lot of things. Only issue I’m having is when I try to run a “Test Connection”, all it sends back is “Failure” and it’s like “ok, is it failure due to incorrect configurations or failure due to network issues or failure due to other things?” There’s soooooo many things that “Failure” could mean. I’ve also looked at the raw response it sends back and it’s just “Failure”.

From what it may look like, seems like it could be an SSL issue on my side. The issue though is that I’ve already added the ca bundle cert for Mattermost into both the trusted store and the default cacerts files on the Jenkins server. I’ve rebooted the VPS itself as well as added the Mattermost IP address to /etc/hosts and I keep coming to the “Failure” error message.

That’s the only reason why I switched to trying to run the notifications using this HTTP Request plug-in.

Highly recommend switching to pipeline. You’ll have much more control and feedback of whats going on and over time.

But thats why i recommended you use a shell or batch freestyle step, you can use curl, or powershell, or anything else to post to mattermost. (see Sending alerts to a Mattermost channel with an incoming webhook which includes some curl examples)

And I think the tokens plugin gives you more access to variables in freestyle. Again this is all supported out of the box for pipelines.

Sorry for the late response, I had a family emergency I had to take care of. I have actually been able to get the Mattermost stuff working now. I was just missing some plugins that allowed me to use the environment variables.