Artifact

JFrog Pipelines Documentation

ft:sourceType
Paligo

An Artifact resource can be used to trigger a step or pipeline on any of the following Artifactory events:

  • Deploy

  • Delete

  • Copy

  • Move

  • Cache

When this resource is added as an input resource to any step, on resource update, the step or the pipeline is triggered.

Important

If there are issues while using Artifact resource, see the Troubleshooting section below for possible solutions.

Note

This resource cannot be added as an output to a step.

See it Live!

Click here to see a live example that uses this resource.

YAML Schema

Rename Resource Name

In your pipeline YAML, whenever you make a change to any tag in the Configuration section, the name of the resource must be renamed. If the resource name is not renamed, any changes to the Configuration section are not taken into consideration during pipeline sync.

The YAML schema for Artifact:

resources:
  name:         <string>
  type: Artifact
  configuration:
    jfrogPlatformProvider:     <JFrogPlatformAccessToken_integration>    # required
    repositories:                                # required
      - repository_name
      - repository_name
    artifactPath:                                # optional
      include:
        - pattern_1
        - pattern_2
      exclude:
        - pattern_1
        - pattern_2
      branches:                                    # required
        include:     <includePattern>            
        exclude:     <excludePattern>   
      buildOn:                                     # required
        deployed:    <boolean>
        deleted:     <boolean>
        copied:      <boolean>
        moved:       <boolean>
        cached:      <boolean>
Tags
name

An alphanumeric string (underscores are permitted) that identifies the resource.

type

Must be Artifact for this resource type.

configuration

Specifies all configuration selections for the resource.

Tag

Description

Required/Optional

jfrogPlatformProvider

The name of the JFrog Platform Access Token integration.

Required

repositories

Used to specify the Artifactory repositories on which the event is applied.

Note

If this tag is not specified, all tags are matched by default.

Required

branches

For use in multibranch pipelines, though it will also work with single branch pipelines. An object where include and exclude regex patterns are used to control which branches are triggered by the resource.

  • Required: When an include pattern is supplied, any branch not matching the pattern will not trigger.

  • Optional: If an exclude pattern is supplied, any branch matching the pattern will not trigger.

Supported regex

The branches tag supports the following regex:

^ $ . * & ? @ = ; : +

Examples:

^gitBranch$ (to trigger for that branch)

example.*

example+.&

example+:&@=.*$

^._example+:&.@=+;?.*$

example+.:&@=*;?1661337986460$

branches.include is required

branches.exclude is optional

buildOn

Used to control whether the resource will be updated on specified events. These are set to false by default.

  • Deployed: Trigger when an artifact is deployed to a repository.

  • Deleted: Trigger when an artifact is deleted from a repository.

  • Moved: Trigger when an artifact is moved from a repository. This will apply on the repositories from which the artifact is moved.

  • Copied: Trigger when an artifact is copied from a repository. This will apply on the repositories from which the artifact is copied.

  • Cached: Trigger when an artifact is cached.

Required

artifactPath

  • include -- (optional) Simple comma separated wildcard patterns for repository artifact paths (with no leading slash). Ant-style path expressions are supported (*, **, ?). For example: "org/apache/**"

  • exclude -- (optional) Simple comma separated wildcard patterns for repository artifact paths (with no leading slash). Ant-style path expressions are supported (*, **, ?). For example: "org/apache/**"

Optional

Environment Variables

Whenever Artifact is used in a step, a set of environment variables is automatically made available that can be used in your step.

Environment Variable

Description

res_<resource_name>_name

Name of the resource

res_<resource_name>_event_type

The type of the event.

res_<resource_name>_event_path

The artifact path that triggered the event.

Examples

Example 1

Rename Resource Name

In your pipeline YAML, whenever you make a change to any tag in the Configuration section, the name of the resource must be renamed. If the resource name is not renamed, any changes to the Configuration section are not taken into consideration during pipeline sync.

resources:
  - name: artifact_1
    type: Artifact
    configuration:
      jfrogPlatformProvider: jfrogPlafromTokenIntegration    # required
      repositories:                            # required
        - example-repo-local
      artifactPath:                            # optional
        include:
          - tools/*
        exclude:
          - tools/exclude/*
      buildOn:                                 # required
        deployed: true
        cached: true
        deleted: true
      branches:                                # required
        include: artifactResource              # required
  - name: artifact_2
    type: Artifact
    configuration:
      jfrogPlatformProvider: myIntegration    # JFrog Platform Access Token integration
      repositories:
        - example-repo-local
      artifactPath:
        include:
          - default/*
          - tools/*
      buildOn:
        deployed: true
      branches:
        include: artifactResource

pipelines:
  - name: my_pipe_1
    configuration:
      jfrogCliVersion: 2
    steps:
      - name: step_1
        type: Bash
        configuration:
          inputResources:
            - name: artifact_1
        execution:
          onExecute:
            - echo "executing step_1"
  - name: my_pipe_2
    steps:
      - name: step_2
        type: Bash
        configuration:
          inputResources:
            - name: artifact_2
        execution:
          onExecute:
            - echo "executing step_2"
            - echo "sync started"
Troubleshooting

When using the Artifact resource in Pipelines, if you see that the pipeline or step is not getting triggered on artifact deployment or event update as configured in the resource, check the following:

  • Ensure that the integration used in the Artifact resource has administrator privileges on the JPD (on that Artifactory). You can either:

    • Create a access token with admin permissions

      or

    • Use the identity token of the user who has administrator privileges

  • Ensure that there are source branches that match the branch pattern mentioned in the Artifact resource’s branches.include.