Hi
I am trying to create new node from my JS application using api request, and i always got error code 400 (bad request)
i cant find in the documentation what is the required fields i need to send and how the url should looks like.
this is my code:
async createNode(agentName: string, url: string): Promise<void> {
try {
const data = JSON.stringify({
name: agentName,
nodeDescription: '',
numExecutors: 1,
remoteFS: 'C:\\Jenkins',
labelString: '',
mode: 'EXCLUSIVE',
retentionStrategy: {
'stapler-class': 'hudson.slaves.RetentionStrategy$Always',
},
launcher: {
'stapler-class': 'hudson.slaves.JNLPLauncher',
},
nodeProperties: {
'stapler-class-bag': 'true',
},
});
const response = await this.axiosInstance.post(
`${url}/computer/doCreateItem?name=${agentName}&type=hudson.slaves.DumbSlave`,
data,
{
headers: {
'Content-Type': 'application/json',
},
},
);
if (response.status !== 200) {
throw new HttpException(
`Failed to create node: ${response.statusText}`,
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
} catch (error) {
throw new HttpException(
`Failed to create node: ${error}`,
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}