Artifactory

Description

This plugin enables you to manage artifacts in Artifactory in a Vela pipeline.

Source Code: https://github.com/go-vela/vela-artifactory

Registry: https://hub.docker.com/r/target/vela-artifactory

Usage

NOTE:

Users should refrain from using latest as the tag for the Docker image.

It is recommended to use a semantically versioned tag instead.

Sample of copying an artifact:

steps:
  - name: copy_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: copy
      path: libs-snapshot-local/foo.txt
      target: libs-snapshot-local/bar.txt
      url: http://localhost:8081/artifactory

Sample of deleting an artifact:

steps:
  - name: delete_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: delete
      path: libs-snapshot-local/foo.txt
      url: http://localhost:8081/artifactory

Sample of setting properties on an artifact:

steps:
  - name: set_properties_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: set-prop
      path: libs-snapshot-local/foo.txt
      props:
        - name: single
          value: foo
        - name: multiple
          values:
            - bar
            - baz
      url: http://localhost:8081/artifactory

Sample of uploading an artifact:

steps:
  - name: upload_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: upload
      path: libs-snapshot-local/
      sources:
        - foo.txt
        - target/*.jar
        - dist/**/*.js
      url: http://localhost:8081/artifactory

Sample of pretending to upload an artifact:

steps:
  - name: upload_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: upload
+     dry_run: true
      path: libs-snapshot-local/
      sources:
        - foo.txt
        - target/*.jar
        - dist/**/*.js
      url: http://localhost:8081/artifactory

Sample of using docker-promote on an artifact:

steps:
  - name: docker_promote_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: docker-promote
      target_repo: libs-snapshot-local
      docker_registry: octocat/hello-world
      tag: latest
      target_docker_registry: octocat/hello-world
      target_tags: "${VELA_BUILD_COMMIT:0:8}"

Secrets

NOTE: Users should refrain from configuring sensitive information in your pipeline in plain text.

Internal

The plugin accepts the following parameters for authentication:

ParameterEnvironment Variable Configuration
api_keyPARAMETER_API_KEY, ARTIFACTORY_API_KEY
passwordPARAMETER_PASSWORD, ARTIFACTORY_PASSWORD
usernamePARAMETER_USERNAME, ARTIFACTORY_USERNAME

Users can use Vela internal secrets to substitute these sensitive values at runtime:

steps:
  - name: copy_artifacts
    image: target/vela-artifactory:latest
    pull: always
+   secrets: [ artifactory_username, artifactory_password ]
    parameters:
      action: copy
      path: libs-snapshot-local/foo.txt
      target: libs-snapshot-local/bar.txt
      url: http://localhost:8081/artifactory
-     username: octocat
-     password: superSecretPassword

This example will add the secrets to the copy_artifacts step as environment variables:

  • ARTIFACTORY_USERNAME=<value>
  • ARTIFACTORY_PASSWORD=<value>

External

The plugin accepts the following files for authentication:

ParameterFile Configuration
api_key/vela/parameters/artifactory/api_key, /vela/secrets/artifactory/api_key, /vela/secrets/managed-auth/api_key
password/vela/parameters/artifactory/password, /vela/secrets/artifactory/password, /vela/secrets/managed-auth/password
username/vela/parameters/artifactory/username, /vela/secrets/artifactory/username, /vela/secrets/managed-auth/username

Users can use Vela external secrets to substitute these sensitive values at runtime:

steps:
  - name: copy_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: copy
      path: libs-snapshot-local/foo.txt
      target: libs-snapshot-local/bar.txt
      url: http://localhost:8081/artifactory
-     username: octocat
-     password: superSecretPassword

This example will read the secret values in the build workspace stored at /vela/secrets/artifactory/*

Parameters

NOTE:

The plugin supports reading all parameters via:

  • environment variables - PARAMETER_* OR ARTIFACTORY_*
  • files - /vela/parameters/artifactory/* OR /vela/secrets/artifactory/*

Any values set from a file takes precedence over values set from the environment.

The following parameters are used to configure the image:

NameDescriptionRequiredDefaultEnvironment Variables
actionaction to perform against ArtifactorytrueN/APARAMETER_ACTION
ARTIFACTORY_ACTION
api_keyAPI key for communication with ArtifactoryfalseN/APARAMETER_API_KEY
ARTIFACTORY_API_KEY
dry_runenables pretending to perform the actionfalsefalsePARAMETER_DRY_RUN
ARTIFACTORY_DRY_RUN
log_levelset the log level for the plugintrueinfoPARAMETER_LOG_LEVEL
ARTIFACTORY_LOG_LEVEL
passwordpassword for communication with ArtifactoryfalseN/APARAMETER_PASSWORD
ARTIFACTORY_PASSWORD
urlArtifactory instance to communicate withtrueN/APARAMETER_URL
ARTIFACTORY_URL
usernameuser name for communication with ArtifactoryfalseN/APARAMETER_USERNAME
ARTIFACTORY_USERNAME
http_client_retriesnumber of times to retry failed http attemptsfalse3PARAMETER_HTTP_CLIENT_RETRIES
ARTIFACTORY_HTTP_CLIENT_RETRIES
http_client_retry_waitamount of milliseconds to wait between failed http attemptsfalse500PARAMETER_HTTP_CLIENT_RETRY_WAIT_MILLISECONDS
ARTIFACTORY_HTTP_CLIENT_RETRY_WAIT_MILLISECONDS
http_client_certfile path to the client certificate to use for TLS communicationfalseN/APARAMETER_HTTP_CLIENT_CERT
ARTIFACTORY_HTTP_CLIENT_CERT
http_client_cert_keyfile path to the client certificate key to use for TLS communicationfalseN/APARAMETER_HTTP_CLIENT_CERT_KEY
ARTIFACTORY_HTTP_CLIENT_CERT_KEY
http_client_insecure_tlsenable insecure TLS communicationfalsefalsePARAMETER_HTTP_CLIENT_INSECURE_TLS
ARTIFACTORY_HTTP_CLIENT_INSECURE_TLS

Copy

The following parameters are used to configure the copy action:

NameDescriptionRequiredDefaultEnvironment Variables
flatenables removing source directory hierarchyfalsefalsePARAMETER_FLAT
ARTIFACTORY_FLAT
pathsource path to copy artifact(s) fromtrueN/APARAMETER_PATH
ARTIFACTORY_PATH
recursiveenables copying sub-directories for the artifact(s)falsefalsePARAMETER_RECURSIVE
ARTIFACTORY_RECURSIVE
targettarget path to copy artifact(s) totrueN/APARAMETER_TARGET
ARTIFACTORY_TARGET

Delete

The following parameters are used to configure the delete action:

NameDescriptionRequiredDefaultEnvironment Variables
pathtarget path to delete artifact(s) fromtrueN/APARAMETER_PATH
ARTIFACTORY_PATH
recursiveenables removing sub-directories for the artifact(s)falsefalsePARAMETER_RECURSIVE
ARTIFACTORY_RECURSIVE

Docker-Promote

The following parameters are used to configure the docker-promote action:

NameDescriptionRequiredDefaultEnvironment Variables
copyset to copy instead of moving the imagefalsetruePARAMETER_COPY
ARTIFACTORY_COPY
docker_registrypath to image in docker registrytrueN/APARAMETER_DOCKER_REGISTRY
ARTIFACTORY_DOCKER_REGISTRY
promote_propsenables setting properties on the promoted artifactfalsefalsePARAMETER_PROMOTE_PROPS
ARTIFACTORY_PROMOTE_PROPS
tagname of the tag for promotingtrueN/APARAMETER_TAG
ARTIFACTORY_TAG
target_docker_registrypath for target image in docker registrytrueN/APARAMETER_TARGET_DOCKER_REGISTRY
ARTIFACTORY_TARGET_DOCKER_REGISTRY
target_reponame of the docker registry containing the imagetrueN/APARAMETER_TARGET_REPO
ARTIFACTORY_TARGET_REPO
target_tagsname of the final tags after promotiontrueN/APARAMETER_TARGET_TAGS
ARTIFACTORY_TARGET_TAGS

Set-Prop

The following parameters are used to configure the set-prop action:

NameDescriptionRequiredDefaultEnvironment Variables
pathtarget path to artifact(s)trueN/APARAMETER_PATH
ARTIFACTORY_PATH
propsproperties to set on the artifact(s)trueN/APARAMETER_PROPS
ARTIFACTORY_PROPS

Upload

The following parameters are used to configure the upload action:

NameDescriptionRequiredDefaultEnvironment Variables
flatenables removing source directory hierarchyfalsefalsePARAMETER_FLAT
ARTIFACTORY_FLAT
include_dirsenables including sub-directories for the artifact(s)falsefalsePARAMETER_INCLUDE_DIRS
ARTIFACTORY_INCLUDE_DIRS
pathtarget path to upload artifact(s) totrueN/APARAMETER_PATH
ARTIFACTORY_PATH
recursiveenables uploading sub-directories for the artifact(s)falsefalsePARAMETER_RECURSIVE
ARTIFACTORY_RECURSIVE
regexpenables reading the sources as a regular expressionfalsefalsePARAMETER_REGEXP
ARTIFACTORY_REGEXP
sourceslist of artifact(s) to uploadtrueN/APARAMETER_SOURCES
ARTIFACTORY_SOURCES

Template

COMING SOON!

Troubleshooting

You can start troubleshooting this plugin by tuning the level of logs being displayed:

steps:
  - name: copy_artifacts
    image: target/vela-artifactory:latest
    pull: always
    parameters:
      action: copy
+     log_level: trace
      path: libs-snapshot-local/foo.txt
      target: libs-snapshot-local/bar.txt
      url: http://localhost:8081/artifactory

Below are a list of common problems and how to solve them: