Skip to content

Commit 2f2e193

Browse files
authored
Merge pull request #37 from nkatzman/correctBash
fix(checkoutCommand) Updating the bash commands to use ! -z instead of -n
2 parents 0067d83 + adddc0a commit 2f2e193

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,9 @@ class BitbucketScm extends Scm {
633633

634634
// Git clone
635635
command.push(`echo Cloning ${checkoutUrl}, on branch ${config.branch}`);
636-
command.push('if [ -n $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; ' +
636+
command.push('if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; ' +
637637
`then export SCM_URL=${sshCheckoutUrl}; ` +
638-
'elif [ -n $SCM_USERNAME ] && [ -n $SCM_ACCESS_TOKEN ]; ' +
638+
'elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; ' +
639639
`then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@${checkoutUrl}; ` +
640640
`else export SCM_URL=https://${checkoutUrl}; fi`
641641
);

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 hostName/orgName/repoName, on branch branchName && if [ -n $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ -n $SCM_USERNAME ] && [ -n $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && echo Reset to SHA shaValue && git reset --hard shaValue && 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 hostName/orgName/repoName, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && echo Reset to SHA shaValue && git reset --hard shaValue && 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 hostName/orgName/repoName, on branch branchName && if [ -n $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ -n $SCM_USERNAME ] && [ -n $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && echo Reset to SHA branchName && git reset --hard branchName && echo Setting user name and user email && git config user.name abcd && git config user.email dev-null@my.email.com && echo Fetching PR and merging with branchName && git fetch origin prBranch && git merge shaValue"
3+
"command": "echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && echo Reset to SHA branchName && git reset --hard branchName && echo Setting user name and user email && git config user.name abcd && git config user.email dev-null@my.email.com && echo Fetching PR and merging with branchName && git fetch origin prBranch && git merge shaValue"
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 hostName/orgName/repoName, on branch branchName && if [ -n $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ -n $SCM_USERNAME ] && [ -n $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && echo Reset to SHA branchName && git reset --hard 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 prBranch && git merge shaValue"
3+
"command": "echo Cloning hostName/orgName/repoName, on branch branchName && if [ ! -z $SCM_CLONE_TYPE ] && [ $SCM_CLONE_TYPE = ssh ]; then export SCM_URL=git@hostName:orgName/repoName; elif [ ! -z $SCM_USERNAME ] && [ ! -z $SCM_ACCESS_TOKEN ]; then export SCM_URL=https://$SCM_USERNAME:$SCM_ACCESS_TOKEN@hostName/orgName/repoName; else export SCM_URL=https://hostName/orgName/repoName; fi && git clone --quiet --progress --branch branchName $SCM_URL $SD_SOURCE_DIR && echo Reset to SHA branchName && git reset --hard 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 prBranch && git merge shaValue"
44
}

0 commit comments

Comments
 (0)