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 |
---|---|---|
| The name of the JFrog Platform Access Token integration. | Required |
| Used to specify the Artifactory repositories on which the event is applied. NoteIf this tag is not specified, all tags are matched by default. | Required |
| For use in multibranch pipelines, though it will also work with single branch pipelines. An object where
Supported regexThe
Examples:
|
|
| Used to control whether the resource will be updated on specified events. These are set to
| Required |
|
| 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
These examples require a GitRepo and JFrog Platform Access Token integration.
The Pipelines DSL for these examples are available in this repository in the JFrog GitHub account.
Click here to see a live example that uses this resource.
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
.