Closed andreprawira closed 11 months ago
I believe I'm having the same issue when trying to do exactly what OP is. Except my issue comes from executing cdk synth with a .ts pipeline definition.
synth: new ShellStep('Synth', {
input: CodePipelineSource.codeCommit(repos, 'main'),
commands: [
'npm ci',
'npm run build',
'npx cdk synth main-TestFunctions-PipelineStack'
],
additionalInputs: {
"../release": CodePipelineSource.codeCommit(repos, 'release')
}
}),
I've looked into this a bit, and it makes sense that this is happening. Thanks for reporting this!
CodePipelineSource.connection()
will end up creating a new CodeStarConnectionSource
using the data you've passed in. It will call the super class Step
with the repo string.
Step
uses whatever was passed in as the identifier, so the id will be identical if the same repository was used twice despite the branch being different
We might want to take the branch name into account here (might be a breaking change), or, we might want to find some way to identify this scenario and adjust the id if so.
@peterwoodworth thanks for replying, i appreciate it, i'd suggest to have the branch name not to be used as the logical name, cause i think that is what's happening here (and please correct me if im wrong, i just started CDK not long ago), here is my suggestion
"source-1": pipelines.CodePipelineSource.connection(self, "logical-name-for-source-1",
repo_string="my-organization/my-repo1",
branch=f"pipeline/{version}/frontend",
connection_arn=infra.code_star_connection,
code_build_clone_output=True,
trigger_on_push=True,
),
"source-2": pipelines.CodePipelineSource.connection(self, "logical-name-for-source-2",
repo_string="my-organization/my-repo1",
branch=f"pipeline/{version}/backend",
connection_arn=infra.code_star_connection,
code_build_clone_output=True,
trigger_on_push=True,
),
That way it would allow checking out the same repo with multiple branches, also out of curiosity are you working for AWS?
I believe there's an additional parameter, action_name
, which has the following description :
The action name used for this source in the CodePipeline. Default: - The repository string
which should probably be used for the id if provided in the constructor. Unfortunately only the repo string is passed.
There was a similar comment provided here : https://github.com/aws/aws-cdk/pull/24767#pullrequestreview-1361843464
This is problematic, as several folks have mentioned, because you can't create a CodePipeline source for different branches of the same repo.
I just hit this issue after a major refactor to upgrade all our packages and to finally get our deployments back up to speed. We were using GitHub Version 1 and upgraded to the CodeStarConnections and we can not longer deploy our environment pipelines that relied on a strict branch naming convention. Any idea when this fix will be available?
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
I'm trying to check out two different branches of the same repo, but are getting the "Node with duplicate id" error message. Below is the code that I have
Expected Behavior
I'm expecting CDK will checkout the code from the same repo except it will use different branch and synth the code as usual
Current Behavior
Reproduction Steps
Possible Solution
No response
Additional Information/Context
If you try to change the
source-2
repo name frommy-repo1
tomy-repo2
for example it would work. I think there is a bug here where CDK is reading that line asNode ID
instead ofrepo name
CDK CLI Version
2.51.0 (build a87259f)
Framework Version
No response
Node.js Version
16.18.0
OS
Windows
Language
Python
Language Version
No response
Other information
No response