Displaying AppVeyor build status badge in a repository

Categories: .NET

Tags: .NET, CI, Tools

 

If you're using AppVeyor for your CI then you can display the build status in your repository readme page. You do that by using the Status Badge. There’s is good documentation on their web site http://www.appveyor.com/docs/status-badges. But if you're doing this for the first time then you might get confused as to which option to choose and where to get the data you need.

If you don't want to read an entire blog about badges then head to your AppVeyor project page, click on the settings link and then click on the Badges link. Search for Sample markdown code, copy that code and put it in your repository page. You're done.

If you're still reading then you want to know more details, so choose the option that suits you better. The examples I will provide are from my randomuser GitHub repository.

Public repositories from GitHub or Bitbucket

If your source code repository is public then you have two options:

  • Use the URL as described above from your project settings
  • Use the URL from your public repository. In this case you need to have only one AppVeyor project.
    The URL has the following format:
    https://ci.appveyor.com/api/projects/status/{github|bitbucket}/{repository} For example:
    https://ci.appveyor.com/api/projects/status/github/ralbu/randomuser

I would prefer the second choice for public repositories. In the first case you need to embed your AppVeyor project id into the url. I'm not sure about the security implications in this case, if let's say you want to make the AppVeyor project private. In this case you don't want to expose that id.

 

Status Badge options

You have three options when displaying a badge:

  • A simple badge. Use the URL with no query string parameters
    https://ci.appveyor.com/api/projects/status/github/ralbu/randomuser

    Retina badge. Add retina=true parameter
    https://ci.appveyor.com/api/projects/status/github/ralbu/randomuser?retina=true

    This parameter will scale the image but the image doesn't look very sharp.
  • SVG badge. Add svg=true parameter
    https://ci.appveyor.com/api/projects/status/github/ralbu/randomuser?svg=true 

    I like this badge and I use it instead of the first two.

 

Building state of the status badge

There is a difference in the status displayed on the badge when the project is queued or in building process on the SVG image compared with other two images.
The SVG badge says 'pending' and the other two say 'building...'

 

Display the status badge in the Markdown format


When using the Markdown format you display the badge status using the following format
[![Alt img description](Badge Url as described above)](The url to your AppVeyor status page.)

For example:

[![Build status](https://ci.appveyor.com/api/projects/status/github/ralbu/randomuser?svg=true)](https://ci.appveyor.com/api/projects/status/github/ralbu/

Conclusion


You have other options to choose from, like displaying the status of a branch. More information can be found on http://www.appveyor.com/docs/status-badgesing

Comments

comments powered by Disqus