From ae16bee248db4fe3786dcac02dc695647838bb83 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Wed, 16 Mar 2022 13:23:20 +0530 Subject: [PATCH 01/17] [fix]: [CI-3633]: Fixed scm exception message --- .../exceptionhandler/handler/SCMExceptionHandler.java | 3 +++ .../io/harness/connector/task/git/GitCommandTaskHandler.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java b/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java index 28256b4ba6bbf..e4d04c8fc21fc 100644 --- a/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java +++ b/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java @@ -34,6 +34,9 @@ public WingsException handleException(Exception exception) { return NestedExceptionUtils.hintWithExplanationException(HintException.HINT_INVALID_GIT_API_AUTHORIZATION, ExplanationException.INVALID_GIT_API_AUTHORIZATION, new InvalidRequestException(exception.getMessage(), USER)); + } else if (errorCode == ErrorCode.INVALID_REQUEST) { + return NestedExceptionUtils.hintWithExplanationException("Something went wrong with SCM", + "SCM is not running with delegate agent", new InvalidRequestException(exception.getMessage(), USER)); } return new InvalidRequestException(exception.getMessage(), USER); } diff --git a/932-connector-task/src/main/java/io/harness/connector/task/git/GitCommandTaskHandler.java b/932-connector-task/src/main/java/io/harness/connector/task/git/GitCommandTaskHandler.java index 3f9c085acfa5d..0e72355bd6650 100644 --- a/932-connector-task/src/main/java/io/harness/connector/task/git/GitCommandTaskHandler.java +++ b/932-connector-task/src/main/java/io/harness/connector/task/git/GitCommandTaskHandler.java @@ -36,6 +36,7 @@ import io.harness.delegate.beans.git.GitCommandExecutionResponse; import io.harness.eraro.ErrorCode; import io.harness.errorhandling.NGErrorHelper; +import io.harness.exception.InvalidRequestException; import io.harness.exception.runtime.SCMRuntimeException; import io.harness.git.GitClientHelper; import io.harness.product.ci.scm.proto.GetUserReposResponse; @@ -132,8 +133,10 @@ private void handleApiAccessValidation(ScmConnector scmConnector, Boolean execut reposResponse = scmDelegateClient.processScmRequest( c -> scmServiceClient.getUserRepos(scmConnector, SCMGrpc.newBlockingStub(c))); } + } catch (InvalidRequestException e) { + throw SCMRuntimeException.builder().message(e.getMessage()).errorCode(ErrorCode.INVALID_REQUEST).build(); } catch (Exception e) { - throw SCMRuntimeException.builder().errorCode(ErrorCode.UNEXPECTED).cause(e).build(); + throw SCMRuntimeException.builder().message(e.getMessage()).errorCode(ErrorCode.UNEXPECTED).cause(e).build(); } if (reposResponse != null && reposResponse.getStatus() > 300) { ErrorCode errorCode = convertScmStatusCodeToErrorCode(reposResponse.getStatus()); From ca9391b6e83991c6985bfa8d8f687b091f9bc4c1 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Wed, 23 Mar 2022 11:29:13 +0530 Subject: [PATCH 02/17] updateded readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0ee0bd4b420f4..cf2837ed55297 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ harness-core Project Dev environment setup instructions ``` + 2. Download and Install Java 8 *Note: Brew will download and install the latest version of OpenJDK/JRE, its recommended to install OpenJDK/JRE_1.8.0_242 to be in sync with the version everyone is using in the team.* From 25ef9363a7e8ea93c5067b560be2b07e80456514 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Thu, 24 Mar 2022 12:42:48 +0530 Subject: [PATCH 03/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf2837ed55297..b49c77be65613 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repo contains code used in the [Harness CD Community Edition](https://githu harness-core Project Dev environment setup instructions ================================================== ## On MacOS - + ### Prerequisities 1. Install Homebrew: ``` From e2ffd43d4b58b64f744e3ae8b17dbdb0c2084853 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Thu, 24 Mar 2022 12:44:37 +0530 Subject: [PATCH 04/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b49c77be65613..500597b9a40c2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ This repo contains code used in the [Harness CD Community Edition](https://github.com/harness/harness-cd-community) which is licensed under the [PolyForm Shield License 1.0.0](./licenses/PolyForm-Shield-1.0.0.txt). This repo also contains code belonging to Harness CD Enterprise Plan which is licensed under the [PolyForm Free Trial License 1.0.0](./licenses/PolyForm-Free-Trial-1.0.0.txt). You may obtain a copy of these licenses in the [licenses](./licenses/) directory at the root of this repository. harness-core Project Dev environment setup instructions -================================================== +==================================================. ## On MacOS ### Prerequisities From 69cb014a77a9ad385c9d2c8bce974dd02c3564bb Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Thu, 24 Mar 2022 12:46:22 +0530 Subject: [PATCH 05/17] Update README.md --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 500597b9a40c2..a586f269f1bbf 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,4 @@ -This repo contains code used in the [Harness CD Community Edition](https://github.com/harness/harness-cd-community) which is licensed under the [PolyForm Shield License 1.0.0](./licenses/PolyForm-Shield-1.0.0.txt). This repo also contains code belonging to Harness CD Enterprise Plan which is licensed under the [PolyForm Free Trial License 1.0.0](./licenses/PolyForm-Free-Trial-1.0.0.txt). You may obtain a copy of these licenses in the [licenses](./licenses/) directory at the root of this repository. - -harness-core Project Dev environment setup instructions -==================================================. -## On MacOS - +This repo contains code used in the [Harness CD Community Edition](https://github.com/harness/harness-cd-community) which is licensed under the [PolyForm Shield License 1.0.0](./licenses/PolyForm-Shield-1.0.0.txt). This repo also contains code belonging to Harness CD Enterprise Plan which is licensed under the [PolyForm Free Trial License 1.0.0](./licenses/PolyForm-Free-Trial-1.0.0.txt). You may obtain a copy of these licenses in the [licenses](./licenses/) directory at the root o ### Prerequisities 1. Install Homebrew: ``` From cea6461fdb9f6bed5b6de92fba74ffe6c6f58221 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Thu, 24 Mar 2022 12:53:31 +0530 Subject: [PATCH 06/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a586f269f1bbf..55b3454a0db62 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/H Complete this step only if you are actively working with the protocol buffer files. ``` brew tap bufbuild/buf -brew install buf +brew install bufsdcds ``` To check if your protobuf files are according to the coding standards execute in the root of the repo From ed2c9392dff043b5bff5dc1542c02653bfeead85 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Thu, 24 Mar 2022 13:03:02 +0530 Subject: [PATCH 07/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 55b3454a0db62..516d9be545f73 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repo contains code used in the [Harness CD Community Edition](https://githu ``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` - +vfgvfg 2. Download and Install Java 8 From b6d0cf3d28b70edea417fc055bd8c7e553466d71 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Thu, 24 Mar 2022 13:07:55 +0530 Subject: [PATCH 08/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 516d9be545f73..8782961ee26ca 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ This repo contains code used in the [Harness CD Community Edition](https://github.com/harness/harness-cd-community) which is licensed under the [PolyForm Shield License 1.0.0](./licenses/PolyForm-Shield-1.0.0.txt). This repo also contains code belonging to Harness CD Enterprise Plan which is licensed under the [PolyForm Free Trial License 1.0.0](./licenses/PolyForm-Free-Trial-1.0.0.txt). You may obtain a copy of these licenses in the [licenses](./licenses/) directory at the root o ### Prerequisities 1. Install Homebrew: -``` +```vfvf /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` vfgvfg From ddf417fba53ee44968c44c9faa3675e7421c6c6f Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Wed, 13 Apr 2022 14:00:34 +0530 Subject: [PATCH 09/17] fix: [CI-3604]: fixed issue with www in url --- .../service/impl/NGTriggerServiceImpl.java | 2 +- .../java/io/harness/git/GitClientHelper.java | 10 ++- .../io/harness/git/GitClientHelperTest.java | 62 +++++++++++++++++++ 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java b/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java index 81a7c2b83c674..1b812616ce525 100644 --- a/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java +++ b/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java @@ -134,7 +134,7 @@ public class NGTriggerServiceImpl implements NGTriggerService { private static final String TRIGGER = "trigger"; private static final String INPUT_YAML = "inputYaml"; - private static final String DUP_KEY_EXP_FORMAT_STRING = "Trigger [%s] already exists"; + private static final String DUP_KEY_EXP_FORMAT_STRING = "Trigger [%s] already exists or is soft deleted"; @Override public NGTriggerEntity create(NGTriggerEntity ngTriggerEntity) { diff --git a/960-api-services/src/main/java/io/harness/git/GitClientHelper.java b/960-api-services/src/main/java/io/harness/git/GitClientHelper.java index 6f0fa6737a7f3..dfc5cac207577 100644 --- a/960-api-services/src/main/java/io/harness/git/GitClientHelper.java +++ b/960-api-services/src/main/java/io/harness/git/GitClientHelper.java @@ -135,14 +135,18 @@ public static String getGitOwner(String url, boolean isAccountLevelConnector) { } public static boolean isGithubSAAS(String url) { - return getGitSCM(url).equals("github.com"); + String host = getGitSCM(url); + return host.equals("github.com") || host.equals("www.github.com"); } + public static boolean isGitlabSAAS(String url) { - return getGitSCM(url).contains("gitlab.com"); + String host = getGitSCM(url); + return host.equals("gitlab.com") || host.equals("www.gitlab.com"); } public static boolean isBitBucketSAAS(String url) { - return getGitSCM(url).contains("bitbucket.org"); + String host = getGitSCM(url); + return host.equals("bitbucket.org") || host.equals("www.bitbucket.org"); } public static String getGithubApiURL(String url) { diff --git a/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java b/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java index d8c4d6d8e3c86..a037474acab96 100644 --- a/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java +++ b/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java @@ -20,6 +20,7 @@ import static io.harness.rule.OwnerRule.ABOSII; import static io.harness.rule.OwnerRule.ARVIND; import static io.harness.rule.OwnerRule.DEEPAK; +import static io.harness.rule.OwnerRule.DEV_MITTAL; import static io.harness.rule.OwnerRule.HARSH; import static io.harness.rule.OwnerRule.JAMIE; import static io.harness.rule.OwnerRule.JELENA; @@ -433,4 +434,65 @@ public void testGetChangeType() throws Exception { assertThat(gitClientHelper.getChangeType(RENAME)).isEqualTo(ChangeType.RENAME); assertThat(gitClientHelper.getChangeType(COPY)).isEqualTo(null); } + + @Test + @Owner(developers = DEV_MITTAL) + @Category(UnitTests.class) + public void testGetGithubApiURL() { + assertThat(GitClientHelper.getGithubApiURL("https://github.com/devkimittal/harness-core.git")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("https://www.github.com/devkimittal/harness-core.git")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("https://www.github.com/devkimittal/harness-core")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("https://paypal.github.com/devkimittal/harness-core.git")) + .isEqualTo("https://paypal.github.com/api/v3/"); + assertThat(GitClientHelper.getGithubApiURL("https://github.paypal.com/devkimittal/harness-core.git")) + .isEqualTo("https://github.paypal.com/api/v3/"); + assertThat(GitClientHelper.getGithubApiURL("git@github.com:harness/harness-core.git")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("git@www.github.com:harness/harness-core.git")) + .isEqualTo("https://api.github.com/"); + } + + @Test + @Owner(developers = DEV_MITTAL) + @Category(UnitTests.class) + public void testGetGitlabApiURL() { + assertThat(GitClientHelper.getGitlabApiURL("https://gitlab.com/devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://www.gitlab.com/devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://gitlab.com/devki.mittal/test")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://paypal.gitlab.com/devki.mittal/test.git")) + .isEqualTo("https://paypal.gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://gitlab.paypal.com/devki.mittal/test.git")) + .isEqualTo("https://gitlab.paypal.com/"); + assertThat(GitClientHelper.getGitlabApiURL("git@gitlab.com:devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("git@www.gitlab.com:devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + } + + @Test + @Owner(developers = DEV_MITTAL) + @Category(UnitTests.class) + public void testGetBitBucketApiURL() { + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@bitbucket.org/devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat( + GitClientHelper.getBitBucketApiURL("https://www.devmittalciv16@bitbucket.org/devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@bitbucket.org/devmittalciv16/ci_3446")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@bitbucket.paypal.org/devmittalciv16/ci_3446")) + .isEqualTo("https://bitbucket.paypal.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@paypal.bitbucket.org/devmittalciv16/ci_3446")) + .isEqualTo("https://paypal.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("git@bitbucket.org:devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("git@www.bitbucket.org:devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + } } From c4308ccaef05b681792eba680da75d828fafb24a Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 11:08:15 +0530 Subject: [PATCH 10/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bdfb6e30f1cef..a2d085f86a181 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ harness-core Project Dev environment setup instructions To setup the recommended version, download the OpenJDK 1.8-242 (jdk8u242-b08) JRE .pkg from [AdoptOpenJDK](https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/tag/jdk8u242-b08) and install it. Make sure to update `JAVA_HOME` and `PATH` accordingly (see step 5). -3. Install bazel: +3. Install bazel:fvvdfv ``` brew install bazelisk From 89a160d6918e5cbf8d634064840d45bfec958dd7 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 11:11:34 +0530 Subject: [PATCH 11/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2d085f86a181..e761c08f028dc 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ echo "export PATH="$PATH:$HOME//bin" >> ~/.zshrc to format .graphql files: you can follow these steps: * `npm install --global prettier@1.19.1` - +csdvdf * `prettier --write --print-width=120 ` - formats given graphql file helper shell scripts: From 7657ea9b27aa650fb2df5a5e04bd607ad4bfd225 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 11:13:41 +0530 Subject: [PATCH 12/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e761c08f028dc..f6eaa807ad328 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ harness-core Project Dev environment setup instructions ### Prerequisities 1. Install Homebrew: -``` +```vdfv /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` From 93e7f80ea84ca7be66dd8b5dd5720f6566ac04aa Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 11:15:40 +0530 Subject: [PATCH 13/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6eaa807ad328..80b921dd6150a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ harness-core Project Dev environment setup instructions ## On MacOS ### Prerequisities -1. Install Homebrew: +1. Install Homebrew:csvfv ```vdfv /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` From e50deb1f3d8aefc8b580ffcc750323494cf1d829 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 11:18:07 +0530 Subject: [PATCH 14/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80b921dd6150a..7e3e148984591 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ harness-core Project Dev environment setup instructions ### Prerequisities 1. Install Homebrew:csvfv ```vdfv -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +/bin/bash -c "$(curl -fsSL httcdfvfps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` From d97a47a0e47a493e7616f28affc52b9e71154336 Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 16:42:43 +0530 Subject: [PATCH 15/17] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 989c3ee0b8d95..68045b37b55e1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ This repo contains code used in the [Harness CD Community Edition](https://githu ```vfvf /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -vfgvfg 2. Download and Install Java 8 From 09f645438ce84fad803bd07d588f8db224ea6b3c Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Sat, 16 Apr 2022 17:09:47 +0530 Subject: [PATCH 16/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68045b37b55e1..029c28ce23701 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ brew install bazelisk ``` brew install npm ``` - +dfsv 5. Set up JAVA_HOME: create or add this to your bash profile `~/.bashrc` or `~/.zshrc` file and add following line: ``` export JAVA_HOME=$(/usr/libexec/java_home -v1.8) From 082e8f6529c6762bfda283f7a136ee4f502da4ed Mon Sep 17 00:00:00 2001 From: Dev Mittal Date: Mon, 18 Apr 2022 16:14:28 +0530 Subject: [PATCH 17/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 029c28ce23701..3ccd462f5d6fe 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repo contains code used in the [Harness CD Community Edition](https://githu ### Prerequisities 1. Install Homebrew: ```vfvf -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +/bin/bash -c "$(curl -fsSL https://ravvvfw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ```