Teamcity build status icon on github: No permission to get data - github

I try to represent Teamcity build status of project on its Github README.md page.
For this purpose I use TeamCity rest API that exposes status icon at URL
<teamcity-root>/app/rest/builds/buildType:%28id:<buildTypeID>%29/statusIcon
For now I have two Github projects and three TeamCity builds for them (separate builds for two branches).
For all three builds URL built by scheme mentioned above gives me expected image. But Github website replaces original image paths from my TeamCity by own paths from github-camo.global.ssl.fastly.net host. And for two from three builds instead of image I expect to see (success or fail) I get image stating 'No permission to get data'. (It doesn't depend on way I insert image into file: with markdown syntax or inline HTML)
Both Github projects are private. TeamCity site requires login in general but status icons don't.
I've checked also that this situation doesn't depend on TeamCity service hook usage.
I'll be glad to hear any idea on subject.

The settings is in
Project -> Build Configuration Settings -> General Settings -> "enable status widget"
See Teamcity build badge on github

I've found the problem. It was not related to Github. It appears that Status Widget was not enabled for builds in question and in such situation status icon requires login. Enabling the widget solves the problem

Related

How to display a VSTS Build Badge in a README.md file hosted on GitHub?

I have developed a tiny library that I chose to host on GitHub. The code is being built by a VSTS build and published as a NuGet package.
I have written a README.md file and I am trying to include a Build badge on it, as described in the Microsoft documentation. Consequently, I have added the following line in the MD file and replaced the placeholders accordindly:
![Build status](https://{my-organisation}.visualstudio.com/{my-project}/_apis/build/status/{my-build-definition-name}?branch=master)
The problem is that the link is not accessible to anyone that is not logged-in on VSTS and I end up with a 'broken' link on my readme page:
Question
What must be done to make the VSTS Build Badge available to a GitHub repo?
I suppose you must include an authentication token of sorts in order to have at least read-access to the VSTS build from your GitHub page.
Note that the documentation lists also multiple pending issues, including MicrosoftDocs/vsts-docs issue 1499:
Build status badge added to GitHub readme doesn't show up.
So this is still in progress.
On that last issue, it says:
This is due to public vs. private projects.
If you make your project public the image URL will render.
There are other potential workarounds we are looking at for the doc.
See "Change the project visibility, public or private".

Adding embedded build status icon to github

I'm trying to add status icon from Jenkins to GitHub README.md file but the icon doesn't display.
The Embeddable Build Status Icon plugin is installed on Jenkins.
I searched for solutions and found out that I need to change the "configure security" on Jenkins (I activated the Job->ViewStatus checkbox at the "Matrix-based security" for the Anonymous user) but it didn't work.
I tried to add someone else status icon to the README file and it works, so I think the problem is from Jenkins.
The row that I'm trying to add to README is:
![Build Status](http://3.213.40.221:8080/buildStatus/icon?job=1_Load_Build_Staging)
The link status icon works, but doesn't display on README
Anyone have any idea how to fix it?
Github caches README images, according to Aggressive image caching breaks image badges #24, so my guess is that either:
Your build icon is not visible to Github's caching proxy, or
Your jenkins status server is not serving correct HTTP caching headers

Teamcity build badge on github

I wanted to add a teamcity build badge on my github page.My repository is a private github repository.
I started of by including the code below as the link said.
<a href="http://teamcity/viewType.html?buildTypeId=myID&guest=1">
<img src="http://teamcity/app/rest/builds/buildType(id:myID)/statusIcon"/>
</a>
The problem I got stuck at then,was that the image was being blocked.I suspected that this was because my teamcity server was on http while my github repo used https.
In my case it is not possible to change teamcity to use https and so this was not an option.
Any workarounds/suggestions for how to get my build badges on github?
Make sure to check "enable status widget" checkbox on the General Setting page:
For anyone looking for the markdown link syntax of the TeamCity build badge, here it is:
[![Build Status](http://teamcity/app/rest/builds/buildType:(id:myID)/statusIcon)](http://teamcity/viewType.html?buildTypeId=myID&guest=1)
For the user pages displayed, GitHub retrieves the images from the server side and replaces the original image with the one cached. That is why, the TeamCity instance should be accessible externally and the status icon should be available to any user: the easiest way to ensure that is to check "enable status widget" as Boris suggested.
The image is also cached quite aggressively by GitHub, so the badge shown can be outdated. Use at least TeamCity 10.0.2 which has added HTTP headers trying to prevent that caching.

Github multiple status checks for pull request

I have a teamcity project running a build against github repo. On completion of the build, it uses a build feature of teamcity named "Report Change Status to Github" which reports the build status using - https://api.github.com
Now I would like to have another teamcity project run a build against the same github repo and report the build status to github.
How do I make github display the 2 status checks differently? Despite the 2 builds reporting status to github, github just displays "1 pending check" or "1 status check completed successfully"
Edit: I didn't realize you already have the plug in installed, but I am going to leave the steps for other users. I think you need separate build configurations and to make sure you customize the context setting.
I was playing with this today and you can't use JetBrains "Commit Status Reporter" to do this. You can use this plugin though: https://github.com/jonnyzzz/TeamCity.GitHub
It wasn't straightforward to install--
Go here (choose Log in as guest): https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt398 and
Click the "View" link in the "Artifacts" column in the latest successful build.
Then you click teamcity.github.zip and it will download a zip file
Then you upload that zip to TeamCity in the plugins section
Once you do that, go to Build Features and click "Add Build Feature" and select "Report change status to GitHub".
Then fill the form out with something like this (Note: You will need this for each build configuration you want reported. I am also running each build on separate agents which might be necessary):
Statuses are created with something called a context:
https://developer.github.com/v3/repos/statuses/#create-a-status
For each commit, the latest status for each context is shown. And for the pull request overall (next to the merge button) the latest per-context statuses of the latest commit in the pull request are shown.
This means that if you want multiple status checks to show up -- those statuses need to be created with different contexts. And that's something defined by the application which is creating statuses, not GitHub. GitHub only displays the statuses.

How to make GitHub correctly show the build status image of the Jenkins Build Status plugin

Here's an example of a project:
https://github.com/storm-enroute/macrogl
The README.md of this project contains a build status image from a Jenkins running on a server somewhere else:
[![Build Status](https://ci.storm-enroute.com:8080/job/public-macrogl/badge/icon)](https://ci.storm-enroute.com:8080/job/public-macrogl/)
This image is rendered perfectly in Stackoverflow and Github static pages, but on the Github website it is cached to the content delivery network called Fastly. Opening the image URL shows "Not found".
Why is this happening?
How do I have the Github web interface render a markdown with such an image correctly?
How do I have the Github web interface render a markdown with such an image correctly?
The syntax is correct.
Some other project leverage such feature (see LibGit2Sharp Readme or libgit2 Readme for instance).
Why is this happening?
Few seconds ago, https://ci.storm-enroute.com:8080/job/public-macrogl/badge/icon was returning a 404 for me. It looks now fixed.
However, there's a possibility that when the CI server is offline/can't be reached, the 404 is temporarily cached by Camo and served until the cache expires.
install jenkins plugin for embeddable-build-status from: https://plugins.jenkins.io/embeddable-build-status
add to your README.md the tags you want:
Plain Link (with view)
http://URL:8080/buildStatus/icon?job=JOB_NAME
Plain Link (without view)
http://URL:8080/buildStatus/icon?job=JOB_NAME
Markdown (with view)
Build Status http://URL:8080/buildStatus/icon?job=JOB_NAME
Markdown (without view)
Build Status http://URL:8080/buildStatus/icon?job=JOB_NAME
3.Configure jenkins security to allow the status view:
Manage Jenkins -> Configure Security -> Authorization -> choose matrix-based security and check the "ViewStatus" box for the Anonymous user.
if admin user is not there, add it and give it permission to all the boxes.
For anyone else spending way more time than intended on this and wanting a little clarity on what link(s) to use after installing the Emeddable Build Status plugin:
If you navigate to the job in the Jenkins (jenkins_home >> repo >> project >> branch), there's a "Emeddable Build Status" widget you can click on the left pane, and it'll show list exactly what links you can use for your specific jobs.
The following URL structure might also get you to the embeddable build status page:
https://<jenkins_host>/job/<github_owner_or_org>/job/<github_repo_name>/job/master/badge/
Update: I had a similar issue. It turned that the cache server requires the image to be hosted behind a HTTPS, with a fully valid SSL certificate chain (CA(s) + cert). Once your server provides the full cert chain, github will display your badge.