I want to use the Groovy script in this post to get Jenkins versions. So I do this, where I change the docker_image_tags_url to point to a Jenkins end point.
// Import the JsonSlurper class to parse Dockerhub API response import groovy.json.JsonSlurper // Set the URL we want to read from, it is MySQL from official Library for this example, limited to 20 results only. docker_image_tags_url = "https://hub.docker.com/v2/repositories/library/jenkins/tags?page_size=30" try { // Set requirements for the HTTP GET request, you can add Content-Type headers and so on... def http_client = new URL(docker_image_tags_url).openConnection() as HttpURLConnection http_client.setRequestMethod('GET') // Run the HTTP request http_client.connect() // Prepare a variable where we save parsed JSON as a HashMap, it's good for our use case, as we just need the 'name' of each tag. def dockerhub_response = [:] // Check if we got HTTP 200, otherwise exit if (http_client.responseCode == 200) { dockerhub_response = new JsonSlurper().parseText(http_client.inputStream.getText('UTF-8')) } else { println("HTTP response error") System.exit(0) } // Prepare a List to collect the tag names into def image_tag_list = [] // Iterate the HashMap of all Tags and grab only their "names" into our List dockerhub_response.results.each { tag_metadata -> image_tag_list.add(tag_metadata.name) } // The returned value MUST be a Groovy type of List or a related type (inherited from List) // It is necessary for the Active Choice plugin to display results in a combo-box return image_tag_list.sort() } catch (Exception e) { // handle exceptions like timeout, connection errors, etc. println(e) } However, it just returns Alpine versions. How can I get the CentOS versions? Thanks, Chris
-- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/41a3985e-8a7a-4efc-9f38-c0664fed9e8dn%40googlegroups.com. |
I essentially want to get this list, but in a JSON format in an HTTP response. But using this link as my docker_image_tags_url value for my script doesn't work of course, that is, it gives a blank list.
https://hub.docker.com/r/jenkins/jenkins/tags?page_size=20&page=1&ordering=last_updated. On Wednesday, November 25, 2020 at 9:40:16 AM UTC-5 [hidden email] wrote: I want to use the Groovy script in this post to get Jenkins versions. So I do this, where I change the docker_image_tags_url to point to a Jenkins end point. You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/365c1f68-145b-499d-a808-bb8b96351386n%40googlegroups.com. |
I essentially want to get this list, but in a JSON format in an HTTP response. But using this link as my docker_image_tags_url value for my script doesn't work of course, that is, it gives a blank list. Website: http://earl-of-code.com
-- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVeiD%3DJGyqKiwiS_bow0QD-kMFQfcOVJ3Rb%3DH37ETwsgJw%40mail.gmail.com. |
That's what I essentially have already. Just need the correct docker_image_tags_url value, and that post didn't tell me.
On Wednesday, November 25, 2020 at 10:22:41 AM UTC-5 slide wrote:
You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/052d273d-4ad7-4379-b5a3-98e498d10b58n%40googlegroups.com. |
The problem probably is that the centos image is not in the first 30 results . You would need to get the next page(s) until you find a centos image.
See https://docs.docker.com/registry/spec/api/#tags for details. And remember that this endpoint has a limit on the numbe rof requests in a certain timeframe, so be sure to cache the result. [hidden email] schrieb am Mittwoch, 25. November 2020 um 16:35:57 UTC+1: That's what I essentially have already. Just need the correct docker_image_tags_url value, and that post didn't tell me. You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/089d862c-c1eb-4484-943a-9a65eeab45efn%40googlegroups.com. |
Yeah that makes sense. Thanks.
Chris On Thursday, November 26, 2020 at 2:50:04 AM UTC-5 [hidden email] wrote: The problem probably is that the centos image is not in the first 30 results . You would need to get the next page(s) until you find a centos image. You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9b0c3b3c-0fc1-4da4-99ca-5ab657d4d9d4n%40googlegroups.com. |
I read the page you linked, and the part regarding tags pagination. I infer from the page that I should be able to get a list of tags with the following.
https://hub.docker.com/v2/repositories/library/jenkins/tags/list But if I paste the URL on my browser, I get "txnid": "REPOSREQ-29168001-2818-486d-9af5-45c455b6155e", "message": "tag 'list' not found", "errinfo": { "api_call_docker_id": "", "api_call_name": "GetRepositoryTag", "api_call_start": "2020-11-26T16:03:21.274810611Z", "api_call_txnid": "REPOSREQ-29168001-2818-486d-9af5-45c455b6155e", "namespace": "library", "repository": "jenkins", "tag": "list" } } On Thursday, November 26, 2020 at 10:10:01 AM UTC-5 [hidden email] wrote: Yeah that makes sense. Thanks. You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0e93cfef-1a67-4c09-9a3d-bff24f987014n%40googlegroups.com. |
try https://registry.hub.docker.com/v2/library/jenkins/tags/list
[hidden email] schrieb am Donnerstag, 26. November 2020 um 17:07:46 UTC+1: I read the page you linked, and the part regarding tags pagination. I infer from the page that I should be able to get a list of tags with the following. You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/147273a9-73d9-43cd-9df7-5d7db526d260n%40googlegroups.com. |
Thanks again. I get the following even though I give it my Docker Hub creds, which i'm able to use to log in.
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Class":"","Name":"library/jenkins","Action":"pull"}]}]} On Friday, November 27, 2020 at 1:48:19 AM UTC-5 [hidden email] wrote: try https://registry.hub.docker.com/v2/library/jenkins/tags/list You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/da7a1128-54c3-4824-ac58-fb5a342c024fn%40googlegroups.com. |
Free forum by Nabble | Edit this page |