Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Brady Holt
Brady Holt

Posted on • Originally published atgeekytidbits.com on

     

TIL: Post to Slack from Jenkins with curl

I recently needed to post to Slack from a Jenkins build but since theSlack Plugin for Jenkins doesn’t provide fine-grained configuration, I used a curl script in a post-build script.

First, I went created a newJenkins CI configuration in Slack and noted the token it gave me ($SLACK_API_TOKEN below). Then, this is the curl script I used:

if ["$GIT_BRANCH" = "origin/master"]thencurl -X POST -H "Content-Type: application/json" \ -d '{"text":"'"$JOB_NAME"' - #'"$BUILD_NUMBER"' Failed on '"$GIT_BRANCH"' branch - '"$BUILD_URL"'"}' \ "https://[domain].slack.com/services/hooks/jenkins-ci?token=$SLACK_API_TOKEN"fi
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Geek, developer at YNAB, voider of warranties
  • Location
    Texas
  • Education
    The University of Texas at Austin
  • Work
    Developer at YNAB
  • Joined

More fromBrady Holt

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp