Show current state of Jenkins build on GitHub repo

前端 未结 12 1611
遥遥无期
遥遥无期 2020-11-28 17:34

Is there a way to show the Jenkins build status on my project\'s GitHub Readme.md?

I use Jenkins to run continuous integration builds. After each commit it ensures

12条回答
  •  我在风中等你
    2020-11-28 18:00

    What I did is quite simple:

    1. Install the Hudson Post Task Plugin
    2. Create a Personal Access Token here : https://github.com/settings/tokens
    3. Add a Post Task Plugin that always put success

      curl -XPOST -H "Authorization: token OAUTH TOKEN" https://api.github.com/repos/:organization/:repos/statuses/$(git rev-parse HEAD) -d "{
        \"state\": \"success\",
        \"target_url\": \"${BUILD_URL}\",
        \"description\": \"The build has succeeded!\"
      }"
      
    4. Add a Post Task Plugin that will put failure if "marked build as failure"

      curl -XPOST -H "Authorization: token OAUTH TOKEN" https://api.github.com/repos/:organization/:repos/statuses/$(git rev-parse HEAD) -d "{
        \"state\": \"failure\",
        \"target_url\": \"${BUILD_URL}\",
        \"description\": \"The build has failed!\"
      }"
      
    5. You can also add a call to pending at the beginning of tests

      curl -XPOST -H "Authorization: token OAUTH TOKEN" https://api.github.com/repos/:organization/:repos/statuses/$(git rev-parse HEAD) -d "{
        \"state\": \"pending\",
        \"target_url\": \"${BUILD_URL}\",
        \"description\": \"The build is pending!\"
      }"
      

    Screenshot of the Post build task configuration

提交回复
热议问题