Skip to content

Instantly share code, notes, and snippets.

@dereckson

dereckson/step1.js

Last active Oct 1, 2020
Embed
What would you like to do?
Regenerate DockerHubBuildTriggers.json
triggers = {};
(function () {
var s = document.createElement('script');
s.setAttribute('src', 'https://code.jquery.com/jquery-3.5.1.min.js');
document.body.appendChild(s);
}());
// Pause as we need jQuery object to be available, and so we need to let time to the browser to load the script
jQuery.getJSON("https://hub.docker.com/v2/repositories/nasqueron/?page_size=100", function (response) {
for (result of response["results"]) {
image = result["namespace"] + "%2F" + result["name"];
jQuery.ajax({
url: "https://hub.docker.com/api/build/v1/nasqueron/source/?image=" + image,
context: {image: image.replace("%2F", "/")}
}).done(function (response) {
object = response["objects"][0]
if (object) {
jQuery.ajax({
url: "https://hub.docker.com/api/build/v1/nasqueron/source/" + object["uuid"] + "/trigger/",
context: {image: object["image"]}
}).done(function (response) {
triggers[this["image"]] = response["objects"][0]["url"]
});
} else {
console.warn("No automated build for " + this["image"])
}
})
}
});
// Pause to let some time to the requests to be processed
// We've got a winner :)
console.log(JSON.stringify(triggers))
@dereckson

This comment has been minimized.

Copy link
Owner Author

@dereckson dereckson commented Oct 1, 2020

This procedure allows to fetch the trigger build URL for each automated build repo.

  1. Go to any Docker Hub page
  2. Ensure you're logged in
  3. Run each step in the browser console (steps allow async calls to succeed)

The final object is a JSON document we can publish to /srv/notifications/storage/app/DockerHubBuildTriggers.js

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