When uploading files to Artifactory using the rtUpload closure, you have the option of setting properties on the files. These properties can be later used to filter and download those files.
In some cases, you may want want to set properties on files that are already in Artifactory. The way to this is very similar to the way you define which files to download or upload: A FileSpec is used to filter the filter on which the properties should be set. The properties to be set are sent outside the File Spec. Here's an example.
rtSetProps ( serverId: 'Artifactory-1', specPath: 'path/to/spec/relative/to/workspace/spec.json', props: 'p1=v1;p2=v2', failNoOp: true )
In the above example:
The serverId property is used to reference pre-configured Artifactory server instance as described in the Creating Artifactory Server Instance section.
The specPath property include a path to a File Spec, which has a similar structure to the File Spec used for downloading files.
The props property defines the properties we'd like to set. In the above example we're setting two properties - p1 and p2 with the v1 and v2 values respectively.
The failNoOp property is optional. Setting it to true will cause the job to fail, if no properties have been set.
You also have the option of specifying the File Spec directly inside the rtSetProps closure as follows.
rtSetProps ( serverId: 'Artifactory-1', props: 'p1=v1;p2=v2', spec: '''{ "files": [{ "pattern": "my-froggy-local-repo", "props": "filter-by-this-prop=yes" }]}''' )
The rtDeleteProps closure is used to delete properties from files in Artifactory, The syntax is pretty similar to the rtSetProps closure. The only difference is that in the rtDeleteProps, we specify only the names of the properties to delete. The names are comma separated. The properties values should not be specified. Here's an example:
rtDeleteProps ( serverId: 'Artifactory-1', specPath: 'path/to/spec/relative/to/workspace/spec.json', props: 'p1,p2,p3', failNoOp: true )
Similarly to the rtSetProps closure, the File Spec can be defined implicitly in inside the closure as shown here:
rtDeleteProps ( serverId: 'Artifactory-1', props: 'p1,p2,p3', spec: '''{ "files": [{ "pattern": "my-froggy-local-repo", "props": "filter-by-this-prop=yes" }]}''' )