Skip to content

Commit

Permalink
feat(core): rerun child pipelines with artifacts (#7422)
Browse files Browse the repository at this point in the history
  • Loading branch information
maggieneterval committed Sep 24, 2019
1 parent fa47f48 commit d7490f9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/scripts/modules/core/src/domain/IExecutionTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface IExecutionTrigger extends ITrigger {
parentExecution?: IExecution;
parentPipelineApplication?: string;
parentPipelineId?: string;
parentPipelineStageId?: string;
parentPipelineName?: string;
type: string;
user: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { Formik, Form } from 'formik';
import { Modal } from 'react-bootstrap';
import { Observable, Subject } from 'rxjs';
import { assign, clone, compact, extend, get, head, uniq, isArray, pickBy } from 'lodash';
import { assign, clone, compact, extend, get, head, uniq, isArray, isEmpty, pickBy } from 'lodash';

import { SubmitButton, ModalClose } from 'core/modal';
import { Application } from 'core/application';
Expand All @@ -23,6 +23,7 @@ import {
IParameter,
IPipeline,
IPipelineCommand,
IPipelineTrigger,
IStage,
ITrigger,
} from 'core/domain';
Expand Down Expand Up @@ -92,17 +93,39 @@ export class ManualExecutionModal extends React.Component<IManualExecutionModalP
};
}

private static getPipelineTriggers(pipeline: IPipeline, trigger: IExecutionTrigger): ITrigger[] {
if (!isEmpty(pipeline.triggers)) {
return pipeline.triggers;
}

/**
* If Pipeline B runs as a stage of Pipeline A, we want manual
* re-runs to behave as though Pipeline B were triggered by Pipeline A,
* so that artifacts from the prior execution are passed to the re-run
* as expected, so we shim the trigger.
*/
if (trigger && trigger.type === 'pipeline' && trigger.parentPipelineStageId) {
return [
{
enabled: true,
parentExecution: trigger.parentExecution,
type: trigger.type,
} as IPipelineTrigger,
];
}

return [];
}

public componentDidMount() {
const { application, pipeline, trigger } = this.props;
let pipelineOptions = [];
let pipelineNotifications: INotification[] = [];
let triggers: ITrigger[] = [];
if (pipeline) {
pipelineNotifications = pipeline.notifications || [];
if (pipeline.triggers) {
triggers = this.formatTriggers(pipeline.triggers);
this.updateTriggerOptions(triggers);
}
const pipelineTriggers = ManualExecutionModal.getPipelineTriggers(pipeline, trigger);
const triggers = this.formatTriggers(pipelineTriggers);
this.updateTriggerOptions(triggers);
} else {
pipelineOptions = application.pipelineConfigs.data.filter(
(c: any) => !c.disabled && PipelineTemplateV2Service.isConfigurable(c),
Expand Down Expand Up @@ -406,7 +429,7 @@ export class ManualExecutionModal extends React.Component<IManualExecutionModalP
}}
/>
)}
{formik.values.trigger && formik.values.trigger.artifacts && (
{!isEmpty(get(formik.values, 'trigger.artifacts')) && (
<div className="form-group">
<label className="col-md-4 sm-label-right">Artifacts</label>
<div className="col-md-8">
Expand Down

0 comments on commit d7490f9

Please sign in to comment.