Skip to content

Instantly share code, notes, and snippets.

@halfhp
Created March 15, 2019 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halfhp/0422fb2dd3f09d1067aef1f42a2af70b to your computer and use it in GitHub Desktop.
Save halfhp/0422fb2dd3f09d1067aef1f42a2af70b to your computer and use it in GitHub Desktop.
Use the circle API to get the link to the latest build for a given project / branch
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var url = new URL(window.location.href)
var user = url.searchParams.get("user")
var repo = url.searchParams.get("repo")
var branch = url.searchParams.get("branch")
var token = url.searchParams.get("token")
var circleUrl = "https://circleci.com/api/v1.1/project/github/" + user + "/" + repo + "/tree/" + branch + "?circle-token=" + token
$.getJSON(circleUrl, function( data ) {
window.location.replace(data[0].build_url)
});
</script>
@halfhp
Copy link
Author

halfhp commented Mar 15, 2019

If your project is private you'll need to generate a circle API token with artifact access and include it as a url param when hitting this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment