Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,9 @@ class PipelineModel extends BaseModel {
break;
}

// Preserve DISABLED state; otherwise set to ACTIVE
const newState = pipeline.state === 'DISABLED' ? 'DISABLED' : 'ACTIVE';

createOrUpdatePromises.push(
this._updateChildPipeline(
pipeline,
Expand All @@ -1085,7 +1088,7 @@ class PipelineModel extends BaseModel {
scmUri,
scmRepo,
name: scmRepo.name,
state: 'ACTIVE'
state: newState
},
scmUrl
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"js-yaml": "^4.1.1",
"lodash": "^4.17.23",
"screwdriver-config-parser": "^12.0.0",
"screwdriver-data-schema": "^25.12.0",
"screwdriver-data-schema": "^26.1.0",
"screwdriver-logger": "^3.0.0",
"screwdriver-workflow-parser": "^6.0.0"
}
Expand Down
30 changes: 30 additions & 0 deletions test/lib/pipeline.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,36 @@ describe('Pipeline Model', () => {
});
});

it('preserves DISABLED state of child pipeline during sync', () => {
const parsedYaml = hoek.clone(EXTERNAL_PARSED_YAML);
const childPipelineFooMock = getChildPipelineMock({ ...childPipelineGitHubFooConfig, state: 'DISABLED' });

parsedYaml.childPipelines = {
scmUrls: [SCM_URL_GITHUB_FOO]
};

jobs = [mainJob, publishJob];
jobFactoryMock.list.resolves(jobs);
getUserPermissionMocks({ username: 'batman', push: true, admin: true });
scmMock.getFile.resolves('yamlcontentwithscmurls');
parserMock.withArgs({ ...parserConfig, ...{ yaml: 'yamlcontentwithscmurls' } }).resolves(parsedYaml);

pipelineFactoryMock.list
.withArgs({ params: { configPipelineId: testId } })
.resolves([childPipelineFooMock]);

pipeline.childPipelines = {
scmUrls: [SCM_URL_GITHUB_FOO]
};

return pipeline.sync().then(p => {
assert.equal(p.id, testId);
assert.notCalled(childPipelineFooMock.sync);
assert.calledOnce(childPipelineFooMock.update);
assert.equal(childPipelineFooMock.state, 'DISABLED');
});
});

it('does not update child pipelines if does not belong to this parent', () => {
jobs = [mainJob, publishJob];
jobFactoryMock.list.resolves(jobs);
Expand Down