Skip to content

Commit

Permalink
feat(1167): Remove calling exchangeTokenForBuild method (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumada626 authored and tkyi committed Jul 31, 2018
1 parent 6b1a397 commit 9f6eb42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
33 changes: 14 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,20 @@ class JenkinsExecutor extends Executor {

await this._jenkinsJobCreateOrUpdate(jobName, xml);

// exchange temporal JWT to build JWT
return this.exchangeTokenForBuild(config).then((buildToken) => {
config.token = buildToken;

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_BUILD_TIMEOUT: buildTimeout
}
}]
});
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_BUILD_TIMEOUT: buildTimeout
}
}]
});
}

Expand Down
8 changes: 1 addition & 7 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('index', () => {

const buildParams = {
SD_BUILD_ID: String(config.buildId),
SD_TOKEN: 'someBuildToken',
SD_TOKEN: config.token,
SD_CONTAINER: config.container,
SD_API: ecosystem.api,
SD_STORE: ecosystem.store,
Expand Down Expand Up @@ -197,7 +197,6 @@ describe('index', () => {
let buildOpts;
let configuredBuildTimeoutOpts;
let maxBuildTimeoutOpts;
let exchangeTokenStub;
const fakeXml = 'fake_xml';

beforeEach(() => {
Expand Down Expand Up @@ -247,8 +246,6 @@ describe('index', () => {
};

sinon.stub(executor, '_loadJobXml').returns(fakeXml);
exchangeTokenStub = sinon.stub(executor, 'exchangeTokenForBuild');
exchangeTokenStub.resolves('someBuildToken');
config.annotations = {};
});

Expand Down Expand Up @@ -632,7 +629,6 @@ rm -f docker-compose.yml

describe('run without Mocked Breaker', () => {
const fakeXml = 'fake_xml';
let exchangeTokenStub;

beforeEach(() => {
mockery.deregisterMock('circuit-fuses');
Expand All @@ -657,8 +653,6 @@ rm -f docker-compose.yml
jenkinsMock.job.build = sinon.stub(executor.jenkinsClient.job, 'build');

sinon.stub(executor, '_loadJobXml').returns(fakeXml);
exchangeTokenStub = sinon.stub(executor, 'exchangeTokenForBuild');
exchangeTokenStub.resolves('someBuildToken');
});

it('calls jenkins function correctly', (done) => {
Expand Down

0 comments on commit 9f6eb42

Please sign in to comment.