Skip to content

Commit

Permalink
fix: pass eslint (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
att55 authored Jan 29, 2020
1 parent 02839dd commit 26cd707
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 91 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
extends: screwdriver
rules:
no-underscore-dangle: off
max-statements: off
complexity: off
max-lines-per-function: off
72 changes: 49 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ class JenkinsExecutor extends Executor {
}

// delay between retry attempts
return new Promise((resolve) => {
return new Promise(resolve => {
setTimeout(resolve, this.cleanupWatchInterval * 1000);
}).then(() => this._jenkinsJobWaitStop(jobName, timeConsumed + this.cleanupWatchInterval));
}).then(() =>
this._jenkinsJobWaitStop(
jobName,
timeConsumed + this.cleanupWatchInterval
)
);
}

/**
Expand All @@ -123,16 +128,19 @@ class JenkinsExecutor extends Executor {
_loadJobXml(config, annotations) {
const { buildScript, cleanupScript } = this._taskScript(config);
const nodeLabel = annotations[ANNOTATE_BUILD_NODE_LABEL]
? `${this.nodeLabel}-${annotations[ANNOTATE_BUILD_NODE_LABEL]}` : this.nodeLabel;
? `${this.nodeLabel}-${annotations[ANNOTATE_BUILD_NODE_LABEL]}`
: this.nodeLabel;

const variables = {
nodeLabel: xmlescape(nodeLabel),
buildScript: xmlescape(buildScript),
cleanupScript: xmlescape(cleanupScript)
};

return tinytim.renderFile(path.resolve(__dirname, './config/job.xml.tim'),
variables);
return tinytim.renderFile(
path.resolve(__dirname, './config/job.xml.tim'),
variables
);
}

/**
Expand Down Expand Up @@ -174,7 +182,10 @@ class JenkinsExecutor extends Executor {
ui_uri: this.ecosystem.ui
};

const templateFile = path.resolve(__dirname, './config/docker-compose.yml.tim');
const templateFile = path.resolve(
__dirname,
'./config/docker-compose.yml.tim'
);
const composeYml = tinytim.renderFile(templateFile, variables);

const buildScript = [
Expand Down Expand Up @@ -243,26 +254,35 @@ class JenkinsExecutor extends Executor {
this.nodeLabel = options.jenkins.nodeLabel || 'screwdriver';
this.buildTimeout = options.jenkins.buildTimeout || 90;
this.maxBuildTimeout = options.jenkins.maxBuildTimeout || 120;
this.composeCommand = (options.docker && options.docker.composeCommand) || 'docker-compose';
this.launchVersion = (options.docker && options.docker.launchVersion) || 'stable';
this.composeCommand =
(options.docker && options.docker.composeCommand) ||
'docker-compose';
this.launchVersion =
(options.docker && options.docker.launchVersion) || 'stable';
this.prefix = (options.docker && options.docker.prefix) || '';
this.memory = (options.docker && options.docker.memory) || '4g';
this.memoryLimit = (options.docker && options.docker.memoryLimit) || '6g';
this.memoryLimit =
(options.docker && options.docker.memoryLimit) || '6g';

this.buildScript = options.buildScript || '';
this.cleanupScript = options.cleanupScript || '';
this.cleanupTimeLimit = options.cleanupTimeLimit || 20;
this.cleanupWatchInterval = options.cleanupWatchInterval || 2;

// need to pass port number in the future
this[baseUrl] = `http://${this.username}:${this[password]}@${this.host}:${this.port}`;
this[
baseUrl
] = `http://${this.username}:${this[password]}@${this.host}:${this.port}`;
this.jenkinsClient = jenkins({
baseUrl: this[baseUrl],
crumbIssuer: true
});

// eslint-disable-next-line no-underscore-dangle
this.breaker = new Breaker(this._jenkinsCommand.bind(this), options.fusebox);
this.breaker = new Breaker(
this._jenkinsCommand.bind(this),
options.fusebox
);
}

/**
Expand All @@ -281,27 +301,33 @@ class JenkinsExecutor extends Executor {
);

const xml = this._loadJobXml(config, annotations);
// prettier-ignore
const buildTimeout = annotations[ANNOTATE_BUILD_TIMEOUT]
? Math.min(annotations[ANNOTATE_BUILD_TIMEOUT], this.maxBuildTimeout)
? Math.min(
annotations[ANNOTATE_BUILD_TIMEOUT],
this.maxBuildTimeout
)
: this.buildTimeout;

await this._jenkinsJobCreateOrUpdate(jobName, xml);

return this.breaker.runCommand({
module: 'job',
action: 'build',
params: [{
name: jobName,
parameters: {
SD_BUILD_ID: String(config.buildId),
SD_TOKEN: config.token,
SD_CONTAINER: config.container,
SD_API: this.ecosystem.api,
SD_STORE: this.ecosystem.store,
SD_UI: this.ecosystem.ui,
SD_BUILD_TIMEOUT: buildTimeout
params: [
{
name: jobName,
parameters: {
SD_BUILD_ID: String(config.buildId),
SD_TOKEN: config.token,
SD_CONTAINER: config.container,
SD_API: this.ecosystem.api,
SD_STORE: this.ecosystem.store,
SD_UI: this.ecosystem.ui,
SD_BUILD_TIMEOUT: buildTimeout
}
}
}]
]
});
}

Expand Down
Loading

0 comments on commit 26cd707

Please sign in to comment.