After Build Info Save Worker Code Sample

JFrog Platform Administration Documentation

Content Type
Administration / Platform
ft:sourceType
Paligo

The following section provides a sample code for a Before Upload worker.

export default async (context: PlatformContext, data: AfterBuildInfoSaveRequest): Promise<AfterBuildInfoSaveResponse> => {
  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",
        executionStatus: Status.STATUS_SUCCESS,
  };
};

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.

{
  "build": {
    "name": "buildName",  // The name of the build, used for identification.
    "number": "buildNumber",  // A unique identifier for this build instance.
    "started": "startDate",  // The date and time when the build process started.
    "buildAgent": "buildAgent",  // The name of the build agent that executed the build.
    "agent": "agent",  // Another identifier for the build agent.
    "durationMillis": 1000,  // Total time taken for the build in milliseconds.
    "principal": "principal",  // The user responsible for initiating the build.
    "artifactoryPrincipal": "artifactoryPrincipal",  // User associated with artifact storage.
    "url": "url",  // A link to the build details or logs.
    "parentName": "parentName",  // Name of the parent build, if applicable.
    "parentNumber": "parentNumber",  // Unique identifier for the parent build.
    "buildRepo": "buildRepo",  // Repository where the source code for the build is stored.
    "modules": [  // List of modules included in this build.
      {
        "id": "module1",  // Unique identifier for the module.
        "artifacts": [  // Collection of artifacts produced by the module.
          {
            "name": "name",  // Name of the artifact (output file/package).
            "type": "type",  // Type/category of the artifact (e.g., jar, zip).
            "prop": "prop",  // Additional properties of the artifact.
            "remotePath": "remotePath",  // Path where the artifact is stored remotely.
            "properties": "prop2"  // Other metadata related to the artifact.
          }
        ],
        "dependencies": [  // List of dependencies required by the module.
          {
            "id": "id",  // Unique identifier for the dependency.
            "scopes": "scopes",  // Scopes in which the dependency is used (e.g., compile, runtime).
            "requestedBy": "requestedBy"  // Identifies who requested the dependency.
          }
        ]
      }
    ],
    "releaseStatus": "releaseStatus",  // Current status of the build in terms of release readiness.
    "promotionStatuses": [  // History of promotional statuses for this build.
      {
        "status": "status",  // Current status of the promotion process (e.g., promoted, rejected).
        "comment": "comment",  // Remarks associated with the promotional status.
        "repository": "repository",  // Repository related to the promotional status.
        "timestamp": "timestamp",  // Date and time when the promotional status was recorded.
        "user": "user",  // User who made the promotional change.
        "ciUser": "ciUser"  // User under which the CI process ran during promotion.
      }
    ]
  }
}
Response
{
  "data": {
    "message": "proceed" // Message to print to the log. If there is an error it will be printed as a warning
  },
  "executionStatus": "STATUS_SUCCESS"
}
  • message : This is a mandatory field.