HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

post jenkins build console output to slack

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
slackjenkinsoutputpostconsolebuild

Problem

I know how to notify build status using the slack notification plugin. I can seeproject - #buildnumber Success after 1 min 18 sec (Open) in my slack channel. But I want the console output to be sent to slack as well (upon failure) instead of a link. I am using free style project since I need some scripts to build my project. The purpose is that I want engineers to know the result of their build without granting them Jenkins access.
edit:

if console log can be uploaded as a text, would be also good. Other forms of 'output' would be welcome as well.
new edit:

I found the answer by myself.

Solution

I figured it out by myself, there is no plugin needed.

build.sh &> /dev/stdout | tee jenkins.txt
and then curl -F file=@jenkins.txt -F channels=yourchannel -H "Authorization: Bearer your token" https://slack.com/api/files.upload

There is no '#' needed for slack channel and channel should not be private.

And if you use buils.sh | tee jenkins.log then you can't get the log from stderr.

Context

StackExchange DevOps Q#5205, answer score: 5

Revisions (0)

No revisions yet.