After Move Worker Code Sample

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

The following section provides a sample code for a 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": { // Various immutable move metadata
   "repoPath": { // The repository path object of the request
     "key": "key", // The repository key
     "path": "path", // The path itself
     "id": "key:path", // The key:path combination
     "isRoot": false, // Is the path the root?
     "isFolder": false // Is the path a folder?
   },
   "contentLength": 100, // The deploy request content length
   "lastModified": 1, // Last modification time that occurred
   "trustServerChecksums": false, // Is the request trusting the server checksums?
   "servletContextUrl": "base", // The URL that points to Artifactory
   "skipJarIndexing": false, // Is it a request that skips jar indexing?
   "disableRedirect": false, // Is redirect disabled on this request?
   "repoType": 1 // Repository type
 },
   "targetRepoPath: { // The target repository path for the worker)
           "key": "key", // The repository key
           "path": "path", // The path itself
           "id": "key:path", // The key:path combination
           "isRoot": false, // Is the path the root?
           "isFolder": false // Is the path a folder?
       }
}
 "artifactProperties": {  // The properties of the request
   "prop1": {
     "value": [
        "value1",
        "value2"
   }
 },
 "userContext": { // The user context that sends the request
   "id": "id", // The username or subject
   "isToken": false, // Is the context an accessToken?
   "realm": "realm" // The realm of the user
 }
}
Response
{
    /** Message to print to the log, in case of an error it will be printed as a warning */
    message: string;
    /** Indicates whether worker execution succeeded or failed */
    executionStatus?: Status; 
}