mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -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 operation = this.getNodeParameter('operation', 0) as string;
|
||||||
const resource = this.getNodeParameter('resource', 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++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const rundeckApi = new RundeckApi(this);
|
|
||||||
|
|
||||||
if (resource === 'job') {
|
if (resource === 'job') {
|
||||||
if (operation === 'execute') {
|
if (operation === 'execute') {
|
||||||
|
|
|
@ -8,20 +8,12 @@ export interface RundeckCredentials {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RundeckApi {
|
export class RundeckApi {
|
||||||
private credentials: RundeckCredentials;
|
private credentials?: RundeckCredentials;
|
||||||
private executeFunctions: IExecuteFunctions;
|
private executeFunctions: IExecuteFunctions;
|
||||||
|
|
||||||
|
|
||||||
constructor(executeFunctions: IExecuteFunctions) {
|
constructor(executeFunctions: IExecuteFunctions) {
|
||||||
const credentials = executeFunctions.getCredentials('rundeckApi');
|
|
||||||
|
|
||||||
this.executeFunctions = executeFunctions;
|
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 = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'user-agent': 'n8n',
|
'user-agent': 'n8n',
|
||||||
'X-Rundeck-Auth-Token': this.credentials.token,
|
'X-Rundeck-Auth-Token': this.credentials?.token,
|
||||||
},
|
},
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
method,
|
method,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: this.credentials.url + endpoint,
|
uri: this.credentials?.url + endpoint,
|
||||||
body,
|
body,
|
||||||
json: true,
|
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> {
|
executeJob(jobId: string, args: IDataObject[]): Promise<IDataObject> {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue