jenkinsfile
#!/usr/bin/env groovy
import org.jenkinsci.plugins.docker.workflow.Docker
Docker.Image image
String filename  = 'Dockerfile'
String filepath  = '.'
String imageName = 'sandbox:v1'
String buildArgs = ' --no-cache ' +
                   " -f ${filename}" +
                   " ${filepath}/"
docker.withTool( 'devops-docker' ) {
  image = docker.build( imageName, buildArgs )
} // docker.withTool
println image.imageName()
println image.id
docker registry
artifactory
How to clean up old Docker images
def clean_docker():
    import requests
    base_url = 'http://localhost:8081/artifactory/'
    headers = {
        'content-type': 'text/plain',
    }
    data = 'items.find({"name":{"$eq":"manifest.json"},"stat.downloaded":{"$before":"4w"}})'
    myResp = requests.post(base_url+'api/search/aql', auth=('admin', 'password'), headers=headers, data=data)
    for result in eval(myResp.text)["results"]:
        artifact_url = base_url+ result['repo'] + '/' + result['path']
        requests.delete(artifact_url, auth=('admin', 'password'))      <----- [[[[[THIS WILL DELETE FILES]]]]]]
if __name__ == '__main__':
    clean_docker()
How to Delete Old Docker Images
[!TIP]
$ items.find({“name”:{“$eq”:”manifest.json”},”stat.downloaded”:{“$before”:”4w”}})