Skip to content

Publish to Artifactory using jfrog cli

This cookbook is an example of a publishers section that uses the jfrog cli to upload files to Artifactory. It is an alternative to using the Artifactory Publisher to upload to artifactory.

The benefit of this method is that it uses the jfrog cli configuration instead of environment variables for configuration.

This assumes you have the jfrog cli downloaded and in your path, and configured with an API key.

publishers:
- name: artifactory
 cmd: >-
   jfrog rt u "{{ .ArtifactName }}" "my-repository/{{ tolower .Env.PROJECT_KEY }}/{{ tolower .ProjectName }}/{{ .Version }}/"
 dir: "{{ dir .ArtifactPath }}"

Example of a publishers section pushing files to a Artifactory instance using jfrog cli with api key in environment

publishers:
- name: artifactory
 cmd: >-
   jfrog rt u "{{ .ArtifactName }}" "my-repository/{{ tolower .Env.PROJECT_KEY }}/{{ tolower .ProjectName }}/{{ .Version }}/" --api-key "{{ .Env.ARTIFACTORY_API_KEY }}"
 dir: "{{ dir .ArtifactPath }}"