File tree Expand file tree Collapse file tree 4 files changed +40
-7
lines changed
src/PostSharp.Engineering.BuildTools/ContinuousIntegration/TeamCity Expand file tree Collapse file tree 4 files changed +40
-7
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ protected BuildStep( DockerSpec? dockerSpec )
2424 protected void AddParameter ( BuildConfigurationParameter parameter ) => this . _parameters . Add ( parameter ) ;
2525
2626 public abstract string GenerateTeamCityCode ( ) ;
27-
27+
2828 public virtual void InsertPrerequisites ( IReadOnlyList < BuildStep > previousSteps , Action < BuildStep > addStep )
2929 {
3030 if ( this . _dockerSpec != null )
Original file line number Diff line number Diff line change @@ -368,7 +368,8 @@ private static TeamCityBuildConfiguration CreateBuildConfiguration(
368368 BuildTriggers = configurationProperties . BuildConfigurationInfo . BuildTriggers ,
369369 SnapshotDependencies = configurationProperties . SnapshotDependenciesForBuildConfiguration ,
370370 SourceDependencies = product . BuildRequiresSourceDependencies ? productProperties . SourceDependencies : [ ] ,
371- IsSshAgentRequired = requiresUpstreamCheck && productProperties . IsRepoRemoteSsh
371+ IsSshAgentRequired = requiresUpstreamCheck && productProperties . IsRepoRemoteSsh ,
372+ RequiresCommitStatusPublisher = true
372373 } ;
373374
374375 return teamCityBuildConfiguration ;
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ internal class TeamCityBuildConfiguration
4646
4747 public BuildConfigurationParameter [ ] ? Parameters { get ; init ; }
4848
49+ public bool RequiresCommitStatusPublisher { get ; init ; }
50+
4951 public TeamCityBuildConfiguration (
5052 string objectName ,
5153 string name ,
@@ -193,7 +195,7 @@ void AddBuildStep( BuildStep newStep )
193195
194196 var requiresSwabra = allBuildSteps . Count > 0 ;
195197 var requiresSshAgent = this . IsSshAgentRequired ;
196- var requiresAnyFeatures = requiresSwabra || requiresSshAgent ;
198+ var requiresAnyFeatures = requiresSwabra || requiresSshAgent || this . RequiresCommitStatusPublisher ;
197199
198200 // Features.
199201 if ( requiresAnyFeatures )
@@ -211,6 +213,39 @@ void AddBuildStep( BuildStep newStep )
211213 }}" ) ;
212214 }
213215
216+ if ( this . RequiresCommitStatusPublisher )
217+ {
218+ // Report status to GitHub.
219+ writer . WriteLine (
220+ $$ """
221+ commitStatusPublisher {
222+ vcsRootExtId = "{{ this . VcsId }} "
223+ publisher = github {
224+ githubUrl = "https://api.github.com"
225+ authType = personalToken {
226+ token = "%env.{{ EnvironmentVariableNames . GitHubToken }} %"
227+ }
228+ }
229+ }
230+ """ ) ;
231+
232+ // Integrate with PRs.
233+ writer . WriteLine ( $$ """
234+ pullRequests {
235+ vcsRootExtId = "{{ this . VcsId }} "
236+ provider = github {
237+ authType = token {
238+ token = "%env.{{ EnvironmentVariableNames . GitHubToken }} %"
239+ }
240+ filterTargetBranch = "+:refs/heads/{{ this . DefaultBranch }} "
241+ filterAuthorRole = PullRequests.GitHubRoleFilter.EVERYBODY
242+ }
243+ }
244+
245+
246+ """ ) ;
247+ }
248+
214249 if ( requiresSshAgent )
215250 {
216251 writer . WriteLine (
Original file line number Diff line number Diff line change @@ -37,11 +37,8 @@ public void GenerateTeamcityCode( TextWriter writer )
3737 writer . WriteLine (
3838 @"// This file is automatically generated by `Build.ps1 generate-scripts`.
3939
40- // Both Swabra and swabra need to be imported
4140import jetbrains.buildServer.configs.kotlin.*
42- import jetbrains.buildServer.configs.kotlin.buildFeatures.sshAgent
43- import jetbrains.buildServer.configs.kotlin.buildFeatures.Swabra
44- import jetbrains.buildServer.configs.kotlin.buildFeatures.swabra
41+ import jetbrains.buildServer.configs.kotlin.buildFeatures.*
4542import jetbrains.buildServer.configs.kotlin.buildSteps.powerShell
4643import jetbrains.buildServer.configs.kotlin.failureConditions.*
4744import jetbrains.buildServer.configs.kotlin.triggers.*
You can’t perform that action at this time.
0 commit comments