Automatic Polling for changed Docker Images on Artifactory from Jenkins

9/4/2017

Is there a way in which we can poll for latest docker images in artifactory through Jenkins in the trigger section for a deployment Job.

Use Case : 1.Writing a Kubernetes deployment job via Jenkins which will get triggered when we have the latest docker images in the artifactory repo.

-- Rohan Gupta
artifactory
docker
jenkins
kubernetes

1 Answer

9/4/2017

You can use URLTrigger Plugin to achieve polling for your artifactory deployments.

For Artifactory you can watch the JSON response changes for files in a particular repo by USING REST API.

You can configure the FileList API for your Artifactory, that comes in the below format:

http://org.server.com/artifactory/api/storage/<PATH_TO_FOLDER_OR_REPO>/

This returns a JSON response like this:

{
"uri": "http://localhost:8081/artifactory/api/storage/libs-release-local/org/acme",
"created": ISO8601,
"files" : [
  {
  "uri": "/archived/doc1.txt",
  "size": "253100", //bytes
  "lastModified": ISO8601,
  "folder": "false",
  "sha1": sha1Checksum,
  "mdTimestamps": { "properties" : lastModified (ISO8601) }
  },...
]
}

So if there is a change in your repo, the JSON response will change and this plugin will compare the responses and trigger your Jenkins job.

-- ANIL
Source: StackOverflow