Work with Docker Daemon Directly - Declarative Pipeline Syntax

JFrog Integrations Documentation

ft:sourceType
Paligo

The Jenkins Artifactory Plugin supports working with the docker daemon directly through its REST API. Please make sure ti set up Jenkins to work with docker and Artifasctory as mentioned in the previous section.

Next, let's create an Artifactory server instance as shown blow, or configure it through Manage | Configure System.

rtServer (
    id: 'Artifactory-1',
    url: 'http://my-artifactory-domain/artifactory',
    credentialsId: 'my-credentials-id'
)

Next, here's how you pull a docker image from Artifactory.

Pulling Docker Images from Artifactory

rtDockerPull(
    serverId: 'Artifactory-1',
    image: ARTIFACTORY_DOCKER_REGISTRY + '/hello-world:latest',
    // Host:
    // On OSX: "tcp://127.0.0.1:1234"
    // On Linux can be omitted or null
    host: HOST_NAME,
    sourceRepo: 'docker-remote',
    // If the build name and build number are not set here, the current job name and number will be used:
    buildName: 'my-build-name',
    buildNumber: '17',
    // Optional - Only if this build is associated with a project in Artifactory, set the project key as follows.
    project: 'my-project-key',
        // Jenkins spawns a new java process during this step's execution.
        // You have the option of passing any java args to this new process.
        javaArgs: '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005' 
)

Here's how you push an image to Artifactory

Pushing Docker Images to Artifactory

rtDockerPush(
    serverId: 'Artifactory-1',
    image: ARTIFACTORY_DOCKER_REGISTRY + '/hello-world:latest',
    // Host:
    // On OSX: 'tcp://127.0.0.1:1234'
    // On Linux can be omitted or null
    host: HOST_NAME,
    targetRepo: 'docker-local',
    // Attach custom properties to the published artifacts:
    properties: 'project-name=docker1;status=stable',
    // If the build name and build number are not set here, the current job name and number will be used:
    buildName: 'my-build-name',
    buildNumber: '17',
    // Optional - Only if this build is associated with a project in Artifactory, set the project key as follows.
    project: 'my-project-key',
        // Jenkins spawns a new java process during this step's execution.
        // You have the option of passing any java args to this new process.
        javaArgs: '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005' 
)

And finally, you have the option of publishing the build-info to Artifactory as follows.

rtPublishBuildInfo (
    serverId: 'Artifactory-1',
    // If the build name and build number are not set here, the current job name and number will be used. Make sure to use the same value used in the rtDockerPull and/or rtDockerPush steps.
    buildName: 'my-build-name',
    buildNumber: '17',
    // Optional - Only if this build is associated with a project in Artifactory, set the project key as follows.
    project: 'my-project-key',
)