@@ -9,37 +9,58 @@ internal class BitBucketPipelines : BuildAgentBase
9
9
public const string BranchEnvironmentVariableName = "BITBUCKET_BRANCH" ;
10
10
public const string TagEnvironmentVariableName = "BITBUCKET_TAG" ;
11
11
public const string PullRequestEnvironmentVariableName = "BITBUCKET_PR_ID" ;
12
- private string ? file ;
12
+ private string ? propertyFile ;
13
+ private string ? ps1File ;
13
14
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
+ }
15
20
16
21
protected override string EnvironmentVariable => EnvironmentVariableName ;
17
22
18
23
public override string GenerateSetVersionMessage ( GitVersionVariables variables ) => variables . FullSemVer ;
19
24
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 ;
21
28
22
29
public override string [ ] GenerateSetParameterMessage ( string name , string ? value ) => new [ ] { $ "GITVERSION_{ name . ToUpperInvariant ( ) } ={ value } " } ;
23
30
24
31
public override void WriteIntegration ( Action < string ? > writer , GitVersionVariables variables , bool updateBuildNumber = true )
25
32
{
26
- if ( this . file is null )
33
+ if ( this . propertyFile is null || this . ps1File is null )
27
34
return ;
28
35
29
36
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 ... ") ;
31
39
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 } ") ;
33
44
writer ( "" ) ;
34
45
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:") ;
35
50
writer ( " artifacts:" ) ;
36
- writer ( $ " - { this . file } ") ;
51
+ writer ( $ " - { this . ps1File } ") ;
37
52
38
53
var exports = variables
39
54
. Select ( variable => $ "export GITVERSION_{ variable . Key . ToUpperInvariant ( ) } ={ variable . Value } ")
40
55
. ToList ( ) ;
41
56
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 ) ;
43
64
}
44
65
45
66
public override string ? GetCurrentBranch ( bool usingDynamicRepos )
0 commit comments