- Newest
- Most votes
- Most comments
I believe the restartExecutionOnUpdate
property means that it will restart execution when the CodePipeline resource itself is updated; that is, a cdk deploy
takes place that changes the CodePipeline.
In the snippet you've provided, it looks like you are using CodeStar connections to pull from Bitbucket. Changes will need to occur on the BitBucket repo and branch indicated to trigger a new CodePipeline deploy, assuming the connection is correctly established.
I am not familiar with the construct, but I suspect that changing the PipelineProject
and the included build spec won't restart execution because that will result in changes to Code Build, no the CodePipeline.
When the restartExecutionOnUpdate flag is set to True, then any update to the CodePipeline Structure will invoke a restart on the Pipeline. With that being said, this property is only for the CodePipeline Structure itself. This includes the JSON content of the pipeline which can be observed through the GetPipeline API. From the information you provided, it is seen that you are performing an update to the buildspec which is a property of the CodeBuild Project, not the Pipeline.
An update to the buildspec will not change the version of the CodePipeline (e.g. from version 1 to 2), as the pipeline structure will not change. Because the structure is not changing, the restart will not occur.
However, there is a workaround to restart the Pipeline when there is a change to the buildspec which is via the use of 'EnvironmentVariables'. Can add an environment variable with a unique name, not used by the build itself. Its sole purpose is to make the pipeline definition change when the buildspec changes, causing a pipeline restart.
Updating the CodeBuild Action's environment variable should work as it is apart of the CodePipeline structure. As long you are not modifying the CodeBuild Project's environment variable as this is on the project level.
Thanks for you explanation, but I was hoping this would not be the case. My main construct is a cdk pipeline so I'd assume anything changing on this construct would change constitute a restart.
Even for "environmentVariables", which like "buildspec" is also a field of PipelineProject, I would expect a restart. So why does one work without the other. This still feels like a bug.
With the main construct being a pipeline I would say "any" change which causes a new deployment should cause a restart, eg cdk diff.
I do like you creative work around but still seems like a bug.
Relevant content
- Accepted Answerasked 6 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
Thanks for your feedback, although I am still unsure of the expected behavior and perhaps wasnt fully clear in my description.
I am deploying in fact a Pipeline construct, and PipelineProject is the opinionated CodeBuild Project for CodePipelines. In addition, there is a step in the pipeline to do the self update (I purposely left this out for brevity in the example), eg cdk synth and deploy, and synth shows a change in the cloud formation pipeline construct. Furthermore my pipeline does in fact update itself but never restarts.