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", "number": "buildNumber", "started": "startDate", "buildAgent": "buildAgent", "agent": "agent" "durationMillis": 1000, "principal": "principal", "artifactoryPrincipal": "artifactoryPrincipal", "url": "url", "parentName": "parentName" "parentNumber": "parentNumber", "buildRepo": "buildRepo", "modules": [ { "id": "module1", "artifacts": [ { "name": "name", "type": "type", "prop": "prop", "remotePath": "remotePath", "properties": "prop2" } ], "dependencies": [ { "id": "id", "scopes": "scopes", "requestedBy": "requestedBy" } ] } ], "releaseStatus": "releaseStatus", "promotionStatuses": [ { "status": "status", "comment": "comment", "repository": "repository", "timestamp": "timestamp", "user": "user", "ciUser": "ciUser" } ] } }
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; }