- 确保您的AWS CDK Pipeline已与Bitbucket集成,并且已经设置了正确的触发器。
- 您需要检查您的Bitbucket仓库是否配置了正确的Webhook,以触发管道。
以下是一个示例Bitbucket仓库配置的Python代码:
from aws_cdk import (
core,
aws_codepipeline as codepipeline,
aws_codepipeline_actions as actions,
aws_codecommit as codecommit
)
class MyStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# Your Bitbucket repository credentials
bitbucket_conn = codecommit.CfnRepository.ConnectionArnProperty(
arn="YOUR_BITBUCKET_CONNECTION_ARN_HERE"
)
# Creating an S3 Bucket
bucket = s3.Bucket(
self, "MyPipelineBucket",
bucket_name="my-pipeline-bucket"
)
# Creating a CodeCommit Repository
repository = codecommit.Repository(
self, "MyRepository",
repository_name="my-repository-name",
connection_arn=bitbucket_conn
)
# Creating a CodePipeline Artifact Bucket
artifact_bucket = s3.Bucket(
self, "MyArtifactBucket",
bucket_name="my-artifact-bucket"
)
#Creating an AWS CodePipeline using the CodeCommit Repository as input
pipeline = codepipeline.Pipeline(
self, "MyPipeline",
pipeline_name="my-pipeline-name",
artifact_bucket=artifact_bucket
)
#Creating a CodeCommit Source Action to retrieve the source code
source_action = actions.CodeCommitSourceAction(
action_name="CodeCommit",
repository=repository,
output=codepipeline.Artifact("SourceArtifact")
)
#Creating a build Action to compile and upload the Spark Jar to S3
build_action = actions.CodeBuildAction(
action_name="MyBuild",
input=codepipeline.Artifact("SourceArtifact"),
outputs=[codepipeline.Artifact("MyArtifact")],
project=MyBuildProject