Answers: <p>You probably want the console output to be posted as an attachment, not a message, to slack. The <a href="https://github.com/jenkinsci/slack-uploader-plugin" rel="nofollow noreferrer">post to slack</a> plugin might be what you are looking for.</p>
  
  <p>The other thing you could do is create a part of the freestyle job that strips out what you want to a text file, and add that as part of the slack message attachment, in the slack plugin configuration.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-10-18T19:28:58.660Z
Answers: have you successfully set up what you mentioned? strip output to text + slack uploader.
Answers: tikael
Answers: CC BY-SA 4.0
Answers: 2018-10-18T07:57:03.817Z
Answers: 2018-10-18T07:57:03.817Z
Answers: Bruce Becker
Answers: <p>Posting the full stack trace tends to clog up the channel. Here are a few things you can do:</p>
  
  <ul>
  <li>Send build status along with the Jenkins Job link to the Channel so Devs can come back to the link for debugging</li>
  <li>Send stack trace as a file</li>
  <li>Send build status as and link to channel and Stack trace info to the user who committed the code for build</li>
  </ul>
  
  <p>Either way, Post to Slack plugin along with other plugins will help you address this need.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-10-19T05:51:42.593Z
Answers: what are other plugins? As I mentioned, devs won't be granted jenkins access. So I need a way to show log outside of jenkins
Answers: tikael
Answers: CC BY-SA 4.0
Answers: 2018-10-19T02:58:04.020Z
Answers: 2018-10-19T02:58:04.020Z
Answers: JohnK
Answers: <p>I figured it out by myself, there is no plugin needed.</p>
  
  <p><code>build.sh &amp;&gt; /dev/stdout | tee jenkins.txt</code>
  and then <code>curl -F file=@jenkins.txt -F channels=yourchannel -H "Authorization: Bearer your token" https://slack.com/api/files.upload</code></p>
  
  <p>There is no '#' needed for slack channel and channel should not be private. </p>
  
  <p>And if you use <code>buils.sh | tee jenkins.log</code> then you can't get the log from stderr.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-06-21T09:26:07.287Z
Answers: This works great, thanks. For reference, you can post to a private channel if you create a bot, invite the bot to the private channel and use the bot token to upload the file.
Answers: zwessels
Answers: CC BY-SA 4.0
Answers: 2018-10-22T09:25:55.733Z
Answers: 2019-06-21T09:58:42.810Z
Answers: 2019-06-21T09:58:42.810Z
Answers: tikael
Body: <p>I know how to notify build status using the slack notification plugin. I can see<code>project - #buildnumber Success after 1 min 18 sec (Open)</code> 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.</p>
  <h2>edit:</h2>
  <p>if console log can be uploaded as a text, would be also good. Other forms of 'output' would be welcome as well.</p>
  <h2>new edit:</h2>
  <p>I found the answer by myself.</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-11-18T12:53:36.540Z
Comments: Thta code is being input where?
Comments: jas
Comments: CC BY-SA 4.0
Comments: 2019-11-20T21:06:07.353Z
Comments: @jas under the ```Build``` section ```execute shell``` -> ```command```
Comments: tikael
Tags: <jenkins><jenkins-plugins><slack>
Title: post jenkins build console output to slack
UserDisplayName: tikael
ThreadText: # post jenkins build console output to slack
  
  (Asked by: username_0 on 2018-10-18)
  
  I know how to notify build status using the slack notification plugin. I can see`project - #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.
  
  **Tags:** jenkins, jenkins-plugins, slack
  
  > **Comments:**
  > **username_1**: Thta code is being input where?  
  > **username_0**: @username_1 under the ```Build``` section ```execute shell``` -> ```command```  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2018-10-22. Score: 5 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_4**: This works great, thanks. For reference, you can post to a private channel if you create a bot, invite the bot to the private channel and use the bot token to upload the file.  
  
  ---
  
  ### Answer by username_2 on 2018-10-18. Score: 2
  
  You probably want the console output to be posted as an attachment, not a message, to slack. The [post to slack](https://github.com/jenkinsci/slack-uploader-plugin) plugin might be what you are looking for.
  
  The other thing you could do is create a part of the freestyle job that strips out what you want to a text file, and add that as part of the slack message attachment, in the slack plugin configuration.
  
  > **Comments:**
  > **username_0**: have you successfully set up what you mentioned? strip output to text + slack uploader.  
  
  ---
  
  ### Answer by username_3 on 2018-10-19. Score: 1
  
  Posting the full stack trace tends to clog up the channel. Here are a few things you can do:
  
  * Send build status along with the Jenkins Job link to the Channel so Devs can come back to the link for debugging
  * Send stack trace as a file
  * Send build status as and link to channel and Stack trace info to the user who committed the code for build
  
  Either way, Post to Slack plugin along with other plugins will help you address this need.
  
  > **Comments:**
  > **username_0**: what are other plugins? As I mentioned, devs won't be granted jenkins access. So I need a way to show log outside of jenkins  
  
  ---
  
  