Skip to content

Commit cd99fed

Browse files
committed
fix: Change git clone shell command syntax
1 parent 78afc19 commit cd99fed

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ class GithubScm extends Scm {
279279

280280
// Git clone
281281
command.push(`echo Cloning ${checkoutUrl}, on branch ${config.branch}`);
282-
command.push(`if [[ $SCM_CLONE_TYPE = 'ssh' ]]; then export SCM_URL=${sshCheckoutUrl}; ` +
282+
command.push('if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; ' +
283+
`then export SCM_URL=${sshCheckoutUrl}; ` +
283284
'elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; ' +
284285
`then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@${checkoutUrl}; ` +
285286
`else export SCM_URL=https://${checkoutUrl}; fi`);

test/data/commands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "echo Cloning github.com/screwdriver-cd/guide, on branch branchName && if [[ $SCM_CLONE_TYPE = 'ssh' ]]; then export SCM_URL=git@github.com:screwdriver-cd/guide; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/guide; else export SCM_URL=https://github.com/screwdriver-cd/guide; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && git reset --hard 12345 && echo Reset to 12345 && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email dev-null@screwdriver.cd"
3+
"command": "echo Cloning github.com/screwdriver-cd/guide, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@github.com:screwdriver-cd/guide; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/guide; else export SCM_URL=https://github.com/screwdriver-cd/guide; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && git reset --hard 12345 && echo Reset to 12345 && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email dev-null@screwdriver.cd"
44
}

test/data/customPrCommands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "echo Cloning github.com/screwdriver-cd/guide, on branch branchName && if [[ $SCM_CLONE_TYPE = 'ssh' ]]; then export SCM_URL=git@github.com:screwdriver-cd/guide; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/guide; else export SCM_URL=https://github.com/screwdriver-cd/guide; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && git reset --hard branchName && echo Reset to branchName && echo Setting user name and user email && git config user.name pqrs && git config user.email dev-null@my.email.com && echo Fetching PR and merging with branchName && git fetch origin pull/3/head:pr && git merge --no-edit 12345"
3+
"command": "echo Cloning github.com/screwdriver-cd/guide, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@github.com:screwdriver-cd/guide; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/guide; else export SCM_URL=https://github.com/screwdriver-cd/guide; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && git reset --hard branchName && echo Reset to branchName && echo Setting user name and user email && git config user.name pqrs && git config user.email dev-null@my.email.com && echo Fetching PR and merging with branchName && git fetch origin pull/3/head:pr && git merge --no-edit 12345"
44
}

test/data/prCommands.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "sd-checkout-code",
3-
"command": "echo Cloning github.com/screwdriver-cd/guide, on branch branchName && if [[ $SCM_CLONE_TYPE = 'ssh' ]]; then export SCM_URL=git@github.com:screwdriver-cd/guide; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/guide; else export SCM_URL=https://github.com/screwdriver-cd/guide; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && git reset --hard branchName && echo Reset to branchName && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email dev-null@screwdriver.cd && echo Fetching PR and merging with branchName && git fetch origin pull/3/head:pr && git merge --no-edit 12345"
3+
"command": "echo Cloning github.com/screwdriver-cd/guide, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@github.com:screwdriver-cd/guide; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@github.com/screwdriver-cd/guide; else export SCM_URL=https://github.com/screwdriver-cd/guide; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && git reset --hard branchName && echo Reset to branchName && echo Setting user name and user email && git config user.name sd-buildbot && git config user.email dev-null@screwdriver.cd && echo Fetching PR and merging with branchName && git fetch origin pull/3/head:pr && git merge --no-edit 12345"
44
}

0 commit comments

Comments
 (0)