Skip to content

Commit 1d2d93b

Browse files
committed
Git authentication fixes.
1 parent c72773b commit 1d2d93b

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

DockerBuild.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ param(
1717

1818
# This setting is replaced by the generate-scripts command.
1919
$EngPath = 'eng'
20-
$EnvironmentVariables = 'AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AZ_IDENTITY_USERNAME,AZURE_CLIENT_ID,AZURE_CLIENT_SECRET,AZURE_DEVOPS_TOKEN,AZURE_DEVOPS_USER,AZURE_TENANT_ID,DOC_API_KEY,DOWNLOADS_API_KEY,ENG_USERNAME,GITHUB_AUTHOR_EMAIL,GITHUB_REVIEWER_TOKEN,GITHUB_TOKEN,IS_POSTSHARP_OWNED,IS_TEAMCITY_AGENT,NUGET_ORG_API_KEY,SIGNSERVER_SECRET,TEAMCITY_CLOUD_TOKEN,TYPESENSE_API_KEY,VS_MARKETPLACE_ACCESS_TOKEN,VSS_NUGET_EXTERNAL_FEED_ENDPOINTS'
20+
$EnvironmentVariables = 'AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AZ_IDENTITY_USERNAME,AZURE_CLIENT_ID,AZURE_CLIENT_SECRET,AZURE_DEVOPS_TOKEN,AZURE_DEVOPS_USER,AZURE_TENANT_ID,DOC_API_KEY,DOWNLOADS_API_KEY,ENG_USERNAME,GIT_USER_EMAIL,GIT_USER_NAME,GITHUB_AUTHOR_EMAIL,GITHUB_REVIEWER_TOKEN,GITHUB_TOKEN,IS_POSTSHARP_OWNED,IS_TEAMCITY_AGENT,NUGET_ORG_API_KEY,SIGNSERVER_SECRET,TEAMCITY_CLOUD_TOKEN,TYPESENSE_API_KEY,VS_MARKETPLACE_ACCESS_TOKEN,VSS_NUGET_EXTERNAL_FEED_ENDPOINTS'
2121

2222
$dockerContextDirectory = "$EngPath/docker-context"
2323

@@ -97,6 +97,9 @@ if (-not $KeepEnv)
9797
{
9898
$env:ENG_USERNAME = $env:USERNAME
9999
}
100+
101+
$env:GIT_USER_NAME = git config --global user.name
102+
$env:GIT_USER_EMAIL = git config --global user.email
100103

101104
New-EnvJson -EnvironmentVariableList $EnvironmentVariables
102105
}

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,7 @@ ENV NUGET_PACKAGES=c:\packages
7373
# Configure git
7474
ARG SRC_DIR
7575
RUN echo $env:PATH
76-
RUN git config --global --add safe.directory $env:SRC_DIR/
76+
RUN git config --global --add safe.directory $env:SRC_DIR/; `
77+
git config --global user.name $env:GIT_USER_NAME; `
78+
git config --global user.email $env:GIT_USER_EMAIL; `
7779

src/PostSharp.Engineering.BuildTools/Docker/EpilogueComponent.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ ARG MOUNTPOINTS
3939
# Configure git
4040
ARG SRC_DIR
4141
RUN echo $env:PATH
42-
RUN git config --global --add safe.directory $env:SRC_DIR/
42+
RUN git config --global --add safe.directory $env:SRC_DIR/; `
43+
git config --global user.name $env:GIT_USER_NAME; `
44+
git config --global user.email $env:GIT_USER_EMAIL; `
4345
4446
""" );
4547
}

src/PostSharp.Engineering.BuildTools/EnvironmentVariableNames.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public static class EnvironmentVariableNames
2121

2222
// NuGet.org
2323
public const string NuGetOrgApiKey = "NUGET_ORG_API_KEY";
24+
25+
// Git - set by DockerBuild.ps1 from current git config.
26+
public const string GitUserName = "GIT_USER_NAME";
27+
public const string GitUserEmail = "GIT_USER_EMAIL";
2428

2529
// GitHub
2630
public const string GitHubToken = "GITHUB_TOKEN";
@@ -58,6 +62,8 @@ public static class EnvironmentVariableNames
5862
AzureDevOpsToken,
5963
GitHubReviewerToken,
6064
GitHubAuthorEmail,
65+
GitUserEmail,
66+
GitUserName,
6167
NuGetOrgApiKey,
6268
AwsAccessKeyId,
6369
AwsAccessKeySecret,

src/PostSharp.Engineering.BuildTools/Resources/DockerBuild.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ if (-not $KeepEnv)
9797
{
9898
$env:ENG_USERNAME = $env:USERNAME
9999
}
100+
101+
$env:GIT_USER_NAME = git config --global user.name
102+
$env:GIT_USER_EMAIL = git config --global user.email
100103

101104
New-EnvJson -EnvironmentVariableList $EnvironmentVariables
102105
}

0 commit comments

Comments
 (0)