mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
🐛 Fix run deck node (#2285)
This commit is contained in:
parent
a5e714f1c4
commit
3fe5a2ddff
|
@ -163,9 +163,11 @@ export class Rundeck implements INodeType {
|
|||
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const rundeckApi = new RundeckApi(this);
|
||||
await rundeckApi.init();
|
||||
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const rundeckApi = new RundeckApi(this);
|
||||
|
||||
if (resource === 'job') {
|
||||
if (operation === 'execute') {
|
||||
|
|
|
@ -8,20 +8,12 @@ export interface RundeckCredentials {
|
|||
}
|
||||
|
||||
export class RundeckApi {
|
||||
private credentials: RundeckCredentials;
|
||||
private credentials?: RundeckCredentials;
|
||||
private executeFunctions: IExecuteFunctions;
|
||||
|
||||
|
||||
constructor(executeFunctions: IExecuteFunctions) {
|
||||
const credentials = executeFunctions.getCredentials('rundeckApi');
|
||||
|
||||
this.executeFunctions = executeFunctions;
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.executeFunctions.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
this.credentials = credentials as unknown as RundeckCredentials;
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,12 +22,12 @@ export class RundeckApi {
|
|||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'user-agent': 'n8n',
|
||||
'X-Rundeck-Auth-Token': this.credentials.token,
|
||||
'X-Rundeck-Auth-Token': this.credentials?.token,
|
||||
},
|
||||
rejectUnauthorized: false,
|
||||
method,
|
||||
qs: query,
|
||||
uri: this.credentials.url + endpoint,
|
||||
uri: this.credentials?.url + endpoint,
|
||||
body,
|
||||
json: true,
|
||||
};
|
||||
|
@ -47,6 +39,15 @@ export class RundeckApi {
|
|||
}
|
||||
}
|
||||
|
||||
async init() {
|
||||
const credentials = await this.executeFunctions.getCredentials('rundeckApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.executeFunctions.getNode(), 'No credentials got returned!');
|
||||
}
|
||||
|
||||
this.credentials = credentials as unknown as RundeckCredentials;
|
||||
}
|
||||
|
||||
executeJob(jobId: string, args: IDataObject[]): Promise<IDataObject> {
|
||||
|
||||
|
|
Loading…
Reference in a new issue