Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pipelines): Fix pipeline triggers for some templated pipelines #2963

Merged

Conversation

jervi
Copy link
Contributor

@jervi jervi commented Jun 5, 2019

Pipeline triggers and pipeline stages were broken for templated pipelines that use a dynamic source that references an artifact. Resolved by resolving the artifacts a bit earlier (before the preprocessors).

@@ -87,7 +87,7 @@ class DependentPipelineStarter implements ApplicationContextAware {
strategy : suppliedParameters.strategy == true
]

if (pipelineConfig.parameterConfig || !suppliedParameters.empty) {
if (pipelineConfig.parameterConfig || !suppliedParameters.isEmpty()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a bug, suppliedParameters.empty tried to look up the key empty in the map instead of calling the isEmpty() method.

@jervi jervi changed the title fix(pipelines): Fix pipeline triggers for some templated pipelines [DNMY] fix(pipelines): Fix pipeline triggers for some templated pipelines Jun 5, 2019
@jervi
Copy link
Contributor Author

jervi commented Jun 5, 2019

Work in progress, do not merge yet.

Pipeline triggers and pipeline stages were broken for templated pipelines that use a dynamic source that references an artifact. Resolved by resolving the artifacts a bit earlier (before the preprocessors).
@jervi jervi force-pushed the fix_pipeline_triggers_with_dynamic_source branch from 1bb02fb to 424d08a Compare June 7, 2019 08:22
@jervi jervi changed the title [DNMY] fix(pipelines): Fix pipeline triggers for some templated pipelines fix(pipelines): Fix pipeline triggers for some templated pipelines Jun 7, 2019
@jervi
Copy link
Contributor Author

jervi commented Jun 7, 2019

Updated by adding a test and some minor adjustments. Should be ready for review now.
@marchello2000 I don't have permissions to remove the WIP label, can you remove it?

}

if (pipelineConfig.errors != null) {
throw new ValidationException("Pipeline template is invalid", pipelineConfig.errors as List<Map<String, Object>>)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Template parsing errors were silently being swallowed, so I added this to surface them to Deck in a proper way. Without this, the code will fail here with the error Cannot get property 'id' on null object.

@marchello2000
Copy link
Contributor

Updated by adding a test and some minor adjustments. Should be ready for review now.
@marchello2000 I don't have permissions to remove the WIP label, can you remove it?

Sorry, removed - I thought the author can always edit labels.

if (parentPipelineStageId != null) {
pipelineConfig.receivedArtifacts = artifactResolver?.getArtifacts(parentPipeline.stageById(parentPipelineStageId))
} else {
pipelineConfig.receivedArtifacts = artifactResolver?.getAllArtifacts(parentPipeline)
}

pipelineConfig.trigger = trigger
pipelineConfig.expectedArtifacts = expectedArtifacts

def artifactError = null
try {
artifactResolver?.resolveArtifacts(pipelineConfig)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this resolve correctly before the pipeline template is expanded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The artifacts should be found in the trigger, which is not a part of the pipeline template, so yes, I believe so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about closing and opening and resolving and unresolving. I’m on mobile and apparently pressing all the buttons 🙄

In our use case the pipeline definition is the artifact, so we have to resolve the artifacts before we can render the pipeline.

@jervi jervi closed this Jun 7, 2019
@jervi jervi reopened this Jun 7, 2019
Copy link
Contributor

@marchello2000 marchello2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Templates always make my head hurt, but it seems reasonable.
I will let you know if we run into any issues (we have some crazy template use cases)

@jervi
Copy link
Contributor Author

jervi commented Jun 18, 2019

@spinnaker/reviewers Can we get this merged?

@marchello2000
Copy link
Contributor

@jervi : sorry about that, merging now

@marchello2000 marchello2000 merged commit 2e07fcc into spinnaker:master Jun 18, 2019
jervi added a commit to jervi/orca that referenced this pull request Jun 19, 2019
…pinnaker#2963)

Pipeline triggers and pipeline stages were broken for templated pipelines that use a dynamic source that references an artifact. Resolved by resolving the artifacts a bit earlier (before the preprocessors).
(cherry picked from commit 2e07fcc)
@jervi jervi deleted the fix_pipeline_triggers_with_dynamic_source branch August 13, 2019 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants