@@ -499,6 +499,18 @@ interface ThirdPartyGitSourceProps extends GitSourceProps {
499
499
* @default every push and every Pull Request (create or update) triggers a build
500
500
*/
501
501
readonly webhookFilters ?: FilterGroup [ ] ;
502
+
503
+ /**
504
+ * The URL that the build will report back to the source provider.
505
+ * Can use built-in CodeBuild variables, like $AWS_REGION.
506
+ *
507
+ * @see https://docs.aws.amazon.com/codebuild/latest/userguide/create-project-cli.html#cli.source.buildstatusconfig.targeturl
508
+ * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
509
+ *
510
+ * @example "$CODEBUILD_PUBLIC_BUILD_URL"
511
+ * @default - link to the AWS Console for CodeBuild to a particular build execution
512
+ */
513
+ readonly buildStatusUrl ?: string ;
502
514
}
503
515
504
516
/**
@@ -510,6 +522,7 @@ abstract class ThirdPartyGitSource extends GitSource {
510
522
private readonly reportBuildStatus : boolean ;
511
523
private readonly webhook ?: boolean ;
512
524
private readonly webhookTriggersBatchBuild ?: boolean ;
525
+ protected readonly buildStatusUrl ?: string ;
513
526
514
527
protected constructor ( props : ThirdPartyGitSourceProps ) {
515
528
super ( props ) ;
@@ -518,6 +531,7 @@ abstract class ThirdPartyGitSource extends GitSource {
518
531
this . reportBuildStatus = props . reportBuildStatus ?? true ;
519
532
this . webhookFilters = props . webhookFilters || [ ] ;
520
533
this . webhookTriggersBatchBuild = props . webhookTriggersBatchBuild ;
534
+ this . buildStatusUrl = props . buildStatusUrl ;
521
535
}
522
536
523
537
public bind ( _scope : CoreConstruct , project : IProject ) : SourceConfig {
@@ -636,10 +650,53 @@ class S3Source extends Source {
636
650
}
637
651
}
638
652
653
+ /**
654
+ * Common properties between {@link GitHubSource} and {@link GitHubEnterpriseSource}.
655
+ */
656
+ interface CommonGithubSourceProps extends ThirdPartyGitSourceProps {
657
+ /**
658
+ * This parameter is used for the `context` parameter in the GitHub commit status.
659
+ * Can use built-in CodeBuild variables, like $AWS_REGION.
660
+ *
661
+ * @see https://docs.aws.amazon.com/codebuild/latest/userguide/create-project-cli.html#cli.source.buildstatusconfig.context
662
+ * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
663
+ *
664
+ * @example "My build #$CODEBUILD_BUILD_NUMBER"
665
+ * @default "AWS CodeBuild $AWS_REGION ($PROJECT_NAME)"
666
+ */
667
+ readonly buildStatusContext ?: string
668
+ }
669
+
670
+ abstract class CommonGithubSource extends ThirdPartyGitSource {
671
+ private readonly buildStatusContext ?: string ;
672
+
673
+ constructor ( props : CommonGithubSourceProps ) {
674
+ super ( props ) ;
675
+ this . buildStatusContext = props . buildStatusContext ;
676
+ }
677
+
678
+ public bind ( scope : CoreConstruct , project : IProject ) : SourceConfig {
679
+ const superConfig = super . bind ( scope , project ) ;
680
+ return {
681
+ sourceProperty : {
682
+ ...superConfig . sourceProperty ,
683
+ buildStatusConfig : this . buildStatusContext !== undefined || this . buildStatusUrl !== undefined
684
+ ? {
685
+ context : this . buildStatusContext ,
686
+ targetUrl : this . buildStatusUrl ,
687
+ }
688
+ : undefined ,
689
+ } ,
690
+ sourceVersion : superConfig . sourceVersion ,
691
+ buildTriggers : superConfig . buildTriggers ,
692
+ } ;
693
+ }
694
+ }
695
+
639
696
/**
640
697
* Construction properties for {@link GitHubSource} and {@link GitHubEnterpriseSource}.
641
698
*/
642
- export interface GitHubSourceProps extends ThirdPartyGitSourceProps {
699
+ export interface GitHubSourceProps extends CommonGithubSourceProps {
643
700
/**
644
701
* The GitHub account/user that owns the repo.
645
702
*
@@ -658,7 +715,7 @@ export interface GitHubSourceProps extends ThirdPartyGitSourceProps {
658
715
/**
659
716
* GitHub Source definition for a CodeBuild project.
660
717
*/
661
- class GitHubSource extends ThirdPartyGitSource {
718
+ class GitHubSource extends CommonGithubSource {
662
719
public readonly type = GITHUB_SOURCE_TYPE ;
663
720
private readonly httpsCloneUrl : string ;
664
721
@@ -683,7 +740,7 @@ class GitHubSource extends ThirdPartyGitSource {
683
740
/**
684
741
* Construction properties for {@link GitHubEnterpriseSource}.
685
742
*/
686
- export interface GitHubEnterpriseSourceProps extends ThirdPartyGitSourceProps {
743
+ export interface GitHubEnterpriseSourceProps extends CommonGithubSourceProps {
687
744
/**
688
745
* The HTTPS URL of the repository in your GitHub Enterprise installation.
689
746
*/
@@ -700,7 +757,7 @@ export interface GitHubEnterpriseSourceProps extends ThirdPartyGitSourceProps {
700
757
/**
701
758
* GitHub Enterprise Source definition for a CodeBuild project.
702
759
*/
703
- class GitHubEnterpriseSource extends ThirdPartyGitSource {
760
+ class GitHubEnterpriseSource extends CommonGithubSource {
704
761
public readonly type = GITHUB_ENTERPRISE_SOURCE_TYPE ;
705
762
private readonly httpsCloneUrl : string ;
706
763
private readonly ignoreSslErrors ?: boolean ;
@@ -768,6 +825,18 @@ export interface BitBucketSourceProps extends ThirdPartyGitSourceProps {
768
825
* @example 'aws-cdk'
769
826
*/
770
827
readonly repo : string ;
828
+
829
+ /**
830
+ * This parameter is used for the `name` parameter in the Bitbucket commit status.
831
+ * Can use built-in CodeBuild variables, like $AWS_REGION.
832
+ *
833
+ * @see https://docs.aws.amazon.com/codebuild/latest/userguide/create-project-cli.html#cli.source.buildstatusconfig.context
834
+ * @see https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
835
+ *
836
+ * @example "My build #$CODEBUILD_BUILD_NUMBER"
837
+ * @default "AWS CodeBuild $AWS_REGION ($PROJECT_NAME)"
838
+ */
839
+ readonly buildStatusName ?: string ;
771
840
}
772
841
773
842
/**
@@ -776,10 +845,12 @@ export interface BitBucketSourceProps extends ThirdPartyGitSourceProps {
776
845
class BitBucketSource extends ThirdPartyGitSource {
777
846
public readonly type = BITBUCKET_SOURCE_TYPE ;
778
847
private readonly httpsCloneUrl : any ;
848
+ private readonly buildStatusName ?: string ;
779
849
780
850
constructor ( props : BitBucketSourceProps ) {
781
851
super ( props ) ;
782
852
this . httpsCloneUrl = `https://bitbucket.org/${ props . owner } /${ props . repo } .git` ;
853
+ this . buildStatusName = props . buildStatusName ;
783
854
}
784
855
785
856
public bind ( _scope : CoreConstruct , _project : IProject ) : SourceConfig {
@@ -793,6 +864,12 @@ class BitBucketSource extends ThirdPartyGitSource {
793
864
sourceProperty : {
794
865
...superConfig . sourceProperty ,
795
866
location : this . httpsCloneUrl ,
867
+ buildStatusConfig : this . buildStatusName !== undefined || this . buildStatusUrl !== undefined
868
+ ? {
869
+ context : this . buildStatusName ,
870
+ targetUrl : this . buildStatusUrl ,
871
+ }
872
+ : undefined ,
796
873
} ,
797
874
sourceVersion : superConfig . sourceVersion ,
798
875
buildTriggers : superConfig . buildTriggers ,
0 commit comments