Skip to content

Commit 13ba0a2

Browse files
reganbaumbauregan
andauthored
fix(GitClone): Fix git clone script to set the credential helper without passing args from the script invocation (#620)
Co-authored-by: Regan Baum <[email protected]>
1 parent 2a0e2a0 commit 13ba0a2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

template/v2/dirs/etc/sagemaker-ui/git_clone.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ dataZoneDomainId=$(jq -r '.AdditionalMetadata.DataZoneDomainId' < $sourceMetaDat
88
dataZoneUserId=$(jq -r '.AdditionalMetadata.DataZoneUserId' < $sourceMetaData)
99
dataZoneEndPoint=$(jq -r '.AdditionalMetadata.DataZoneEndpoint' < $sourceMetaData)
1010
dataZoneProjectId=$(jq -r '.AdditionalMetadata.DataZoneProjectId' < $sourceMetaData)
11-
dataZoneDomainRegion=$(jq -r '.AdditionalMetadata.DataZoneDomainRegion' < $sourceMetaData)
1211

1312
DEFAULT_DESTINATION_PATH=$HOME/src
1413
DESTINATION_PATH=${1:-$DEFAULT_DESTINATION_PATH}
@@ -48,10 +47,8 @@ if [[ -n "$cloneUrl" ]]; then
4847
if [[ "$cloneUrl" == *"codeconnections"* ]] || [[ "$cloneUrl" == *"codestar-connections"* ]]; then
4948
# Check if the DomainExecutionRoleCreds profile exists in the AWS config file
5049
if grep -q 'DomainExecutionRoleCreds' /home/sagemaker-user/.aws/config; then
51-
# Configure Git to use the AWS CodeCommit credential helper with profile DomainExecutionRoleCreds
52-
git config --global credential.helper "!aws --profile DomainExecutionRoleCreds --region $dataZoneDomainRegion codecommit credential-helper --ignore-host-check $@"
53-
git config --global credential.UseHttpPath true
54-
# Clone the repository using the cloneUrl and gitBranchName
50+
/bin/bash /etc/sagemaker-ui/git_config.sh
51+
# Clone the repository using the cloneUrl and gitBranchName
5552
git clone "$cloneUrl" $DESTINATION_PATH -b "$gitBranchName"
5653
fi
5754
else
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -eux
3+
4+
sourceMetaData=/opt/ml/metadata/resource-metadata.json
5+
dataZoneDomainRegion=$(jq -r '.AdditionalMetadata.DataZoneDomainRegion' < $sourceMetaData)
6+
7+
# Configure Git to use the AWS CodeCommit credential helper with profile DomainExecutionRoleCreds
8+
git config --global credential.helper "!aws --profile DomainExecutionRoleCreds --region $dataZoneDomainRegion codecommit credential-helper --ignore-host-check $@"
9+
git config --global credential.UseHttpPath true

0 commit comments

Comments
 (0)