The following section provides a sample code for an After Move worker.
export default async (context: PlatformContext, data: AfterMoveRequest): Promise<AfterMoveResponse> => { try { const res = await context.clients.platformHttp.get("/artifactory/api/system/ping"); if (res.status === 200) { console.log("Artifactory ping success"); } else { console.warn(`Request was successful and returned status code : ${res.status}`); } catch (error) { console.error(`Request failed with status code ${error.status || "<none>"} caused by : ${error.message}`); } return { message: "proceed", };
Input Parameters
context
Provides baseUrl, token, and clients to communicate with the JFrog Platform (for more information, see PlatformContext).
data
The request with upload details sent by Artifactory.
{ "metadata": { // Object containing metadata information about the artifact "repoPath": { // Information about the current repository path for the artifact "key": "local-repo", // Unique key identifier for the repository "path": "folder/subfolder/my-file", // Path to the specific file within the repository "id": "local-repo:folder/subfolder/my-file", // Unique identifier combining the repository key and path "isRoot": false, // Indicates if the path is a root directory (false means it is nested) "isFolder": false // Indicates if the path is a folder (false means it is a file) }, "contentLength": 100, // Length of the content in bytes "lastModified": 0, // Timestamp of the last modification (0 indicates the file has not been modified) "trustServerChecksums": false, // Indicates whether to trust server checksums for validation "servletContextUrl": "https://jpd.jfrog.io/artifactory", // URL for accessing the servlet context "skipJarIndexing": false, // Indicates whether to skip indexing for JAR files "disableRedirect": false, // Indicates whether HTTP redirects should be disabled "repoType": 1 // Numeric identifier representing the type of repository (e.g., local, remote, virtual) }, "targetRepoPath": { // Object containing information about the target repository path for the artifact "key": "target-repo", // Unique key identifier for the target repository "path": "new_folder/my-file", // Path to the specific file in the target repository "id": "target-repo:new_folder/my-file", // Unique identifier for the target path combining its repository key "isRoot": false, // Indicates if the target path is a root directory (false means it is not) "isFolder": false // Indicates if the target path is a folder (false means it is a file) }, "artifactProperties": { // Object containing properties associated with the artifact "prop1": { // Custom property name "value": [ // Array of values associated with the property "value1", // First value of the property "value2" // Second value of the property ] } }, "userContext": { // Object containing context information about the user making the request "id": "id", // Unique identifier for the user "isToken": false, // Indicates if the user is authenticated via a token (false means they are not) "realm": "realm" // Realm for user authentication context } }
Response
{ "data": { "message": "proceed" // Message to print to the log. In case of an error, it will be printed as a warning. }, "executionStatus": "STATUS_SUCCESS" }
message : This is a mandatory field.