@@ -9,37 +9,58 @@ internal class BitBucketPipelines : BuildAgentBase
99 public const string BranchEnvironmentVariableName = "BITBUCKET_BRANCH" ;
1010 public const string TagEnvironmentVariableName = "BITBUCKET_TAG" ;
1111 public const string PullRequestEnvironmentVariableName = "BITBUCKET_PR_ID" ;
12- private string ? file ;
12+ private string ? propertyFile ;
13+ private string ? ps1File ;
1314
14- public BitBucketPipelines ( IEnvironment environment , ILog log ) : base ( environment , log ) => WithPropertyFile ( "gitversion.properties" ) ;
15+ public BitBucketPipelines ( IEnvironment environment , ILog log ) : base ( environment , log )
16+ {
17+ WithPropertyFile ( "gitversion.properties" ) ;
18+ WithPowershellFile ( "gitversion.ps1" ) ;
19+ }
1520
1621 protected override string EnvironmentVariable => EnvironmentVariableName ;
1722
1823 public override string GenerateSetVersionMessage ( GitVersionVariables variables ) => variables . FullSemVer ;
1924
20- public void WithPropertyFile ( string propertiesFileName ) => this . file = propertiesFileName ;
25+ public void WithPropertyFile ( string propertiesFileName ) => this . propertyFile = propertiesFileName ;
26+
27+ public void WithPowershellFile ( string powershellFileName ) => this . ps1File = powershellFileName ;
2128
2229 public override string [ ] GenerateSetParameterMessage ( string name , string ? value ) => new [ ] { $ "GITVERSION_{ name . ToUpperInvariant ( ) } ={ value } " } ;
2330
2431 public override void WriteIntegration ( Action < string ? > writer , GitVersionVariables variables , bool updateBuildNumber = true )
2532 {
26- if ( this . file is null )
33+ if ( this . propertyFile is null || this . ps1File is null )
2734 return ;
2835
2936 base . WriteIntegration ( writer , variables , updateBuildNumber ) ;
30- writer ( $ "Outputting variables to '{ this . file } ' ... ") ;
37+ writer ( $ "Outputting variables to '{ this . propertyFile } ' for Bash,") ;
38+ writer ( $ "and to '{ this . ps1File } ' for Powershell ... ") ;
3139 writer ( "To import the file into your build environment, add the following line to your build step:" ) ;
32- writer ( $ " - source { this . file } ") ;
40+ writer ( $ "Bash:") ;
41+ writer ( $ " - source { this . propertyFile } ") ;
42+ writer ( $ "Powershell:") ;
43+ writer ( $ " - . .\\ { this . ps1File } ") ;
3344 writer ( "" ) ;
3445 writer ( "To reuse the file across build steps, add the file as a build artifact:" ) ;
46+ writer ( $ "Bash:") ;
47+ writer ( " artifacts:" ) ;
48+ writer ( $ " - { this . propertyFile } ") ;
49+ writer ( $ "Powershell:") ;
3550 writer ( " artifacts:" ) ;
36- writer ( $ " - { this . file } ") ;
51+ writer ( $ " - { this . ps1File } ") ;
3752
3853 var exports = variables
3954 . Select ( variable => $ "export GITVERSION_{ variable . Key . ToUpperInvariant ( ) } ={ variable . Value } ")
4055 . ToList ( ) ;
4156
42- File . WriteAllLines ( this . file , exports ) ;
57+ File . WriteAllLines ( this . propertyFile , exports ) ;
58+
59+ var psExports = variables
60+ . Select ( variable => $ "$GITVERSION_{ variable . Key . ToUpperInvariant ( ) } = \" { variable . Value } \" ")
61+ . ToList ( ) ;
62+
63+ File . WriteAllLines ( this . ps1File , psExports ) ;
4364 }
4465
4566 public override string ? GetCurrentBranch ( bool usingDynamicRepos )
0 commit comments