Skip to content

Commit 5332e31

Browse files
STRY56337138: Addressed error message changes
1 parent 4f82646 commit 5332e31

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This will create a executable sndevopscli in bin folder ( /usr/loca/bin/)
3838
**Running CLI**
3939

4040
```sh
41-
sndevopscli create pakcage --help
41+
sndevopscli create package --help
4242
```
4343
### Removing symlink
4444

@@ -48,22 +48,22 @@ npm unlink .
4848

4949
## Creating Docker image
5050

51-
### Buildng docker image
51+
### Building docker image
5252

5353
```sh
54-
docker build -t dockerusername/sndevops-cli:0.35 .
54+
docker build -t servicenowdocker/sndevops-cli:0.01 .
5555
```
5656

5757
```sh
58-
docker push dockerusername/sndevops-cli:0.35
58+
docker push servicenowdocker/sndevops-cli:0.01
5959
```
6060

6161
## Integrating with gitlab
6262

63-
[Example gitlab project](https://gitlab.k8s.sndevops.xyz/devops-admin/helloworld/-/blob/main/.gitlab-ci.yml?ref_type=heads)
63+
[Example gitlab project](https://gitlab.xxxx.xxxxx.xyz/devops-admin/helloworld/-/blob/main/.gitlab-ci.yml?ref_type=heads)
6464

6565

66-
**Example with passing all ServiceNow info via commandlie**
66+
**Example with passing all ServiceNow info via commandline**
6767

6868
```yaml
6969

@@ -72,7 +72,7 @@ stages:
7272

7373
package:
7474
stage: package
75-
image: sannrao/sndevops-cli:0.35
75+
image: servicenowdocker/sndevops-cli:0.35
7676
script:
7777
- sndevopscli create artifact -a '[{"name":"artifact-name-$CI_JOB_ID","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
7878
- sndevopscli create package -n "package-mame" -a '[{"name":"artifact-name-$CI_JOB_ID","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]
@@ -87,15 +87,15 @@ SNOW_TOKEN = <servicenow-tool-token>
8787
SNOW_TOOLID = <servicenow-tool-id>
8888
```
8989

90-
**Example with passing all ServiceNow info via commandlie**
90+
**Example with passing all ServiceNow info via commandline**
9191
```yaml
9292

9393
stages:
9494
- package
9595

9696
package:
9797
stage: package
98-
image: sannrao/sndevops-cli:0.35
98+
image: servicenowdocker/sndevops-cli:0.35
9999
script:
100100
- sndevopscli create artifact -u <serviceno-url> -t <tool-id> --token <tool-token> -a '[{"name":"artifact-name-$CI_JOB_ID","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
101101
- sndevopscli create package -u <serviceno-url> -t <tool-id> --token <tool-token> -n "package-mame" -a '[{"name":"artifact-name-$CI_JOB_ID","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]
@@ -108,9 +108,9 @@ package:
108108
stages:
109109
- DevOpsChangeApproval
110110

111-
package:
111+
ServiceNow DevOps Change:
112112
stage: DevOpsChangeApproval
113-
image: smrutisnow/sndevops-cli:0.35
113+
image: servicenowdocker/sndevops-cli:0.35
114114
script:
115115
- sndevopscli create change -p '{"changeStepDetails":{"timeout":3600,"interval":100},"attributes":{"short_description":"Automated Software Deployment","description":"Automated Software Deployment.","assignment_group":"XXXXXXX","implementation_plan":"Software update is tested and results can be found in Test Summaries Tab.","backout_plan":"When software fails in production, the previous software release will be re-deployed.","test_plan":"Testing if the software was successfully deployed or not"}}'
116116

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"author": "",
1414
"license": "ISC",
1515
"dependencies": {
16-
"axios": "^1.5.1",
16+
"axios": "^1.6.0",
1717
"commander": "^11.0.0",
1818
"dotenv": "^16.3.1"
1919
}

src/api/artifact/changeRequest.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ChangeRequestManager extends SnDevopsApi {
5656
interval = changeStepDetails.interval;
5757
}
5858
} catch (e) {
59-
throw new Error("Change cannot be created because error occured during parsing of changeRequestDetails.");
59+
throw new Error("Change request cannot be created because changeRequestDetails were not parsed.");
6060
}
6161
}
6262

@@ -106,23 +106,23 @@ class ChangeRequestManager extends SnDevopsApi {
106106
}
107107

108108
if (err.message.includes('ECONNREFUSED') || err.message.includes('ENOTFOUND')) {
109-
throw new Error('Invalid ServiceNow Instance URL. Please correct the URL and try again.');
109+
throw new Error('Change request cannot be created because the ServiceNow Instance URL is invalid. Enter the correct URL and try again.');
110110
}
111111

112112
if (err.message.includes('401')) {
113-
throw new Error('Invalid Credentials. Please correct the credentials and try again.');
113+
throw new Error('The SNOW_TOKEN and SNOW_TOOLID are incorrect. Verify that the GitLab project level variables are configured.');
114114
}
115115

116116
if (err.message.includes('405')) {
117-
throw new Error('Response Code from ServiceNow is 405. Please correct ServiceNow logs for more details.');
117+
throw new Error('Change request cannot be created because response Code from ServiceNow is 405. Please check ServiceNow logs for more details.');
118118
}
119119

120120
if (!err.response) {
121-
throw new Error('No response from ServiceNow. Please check ServiceNow logs for more details.');
121+
throw new Error('Change request cannot be created because no response from ServiceNow. Please check ServiceNow logs for more details.');
122122
}
123123

124124
if (err.response.status == 500) {
125-
throw new Error('Response Code from ServiceNow is 500. Please check ServiceNow logs for more details.')
125+
throw new Error('Change request cannot be created because response Code from ServiceNow is 500. Please check ServiceNow logs for more details.')
126126
}
127127

128128
if (err.response.status == 400) {
@@ -173,7 +173,7 @@ class ChangeRequestManager extends SnDevopsApi {
173173
}
174174

175175
if (error.message == "401") {
176-
throw new Error(`The user credentials are incorrect.`);
176+
throw new Error(`The SNOW_TOKEN and SNOW_TOOLID are incorrect. Verify that the GitLab project level variables are configured.`);
177177
}
178178

179179
if (error.message == "403") {
@@ -367,7 +367,7 @@ class ChangeRequestManager extends SnDevopsApi {
367367
validateChangePayload(changePayload) {
368368
for (var key in changePayload) {
369369
if (changePayload.hasOwnProperty(key) && !changePayload[key]) {
370-
throw new Error(`Change cannot be created as Key: ${key} has a null value.`);
370+
throw new Error(`Change request cannot be created as Key: ${key} has a null value.`);
371371
}
372372
}
373373
}

src/api/base/sndevopsApi.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class SndevopsApi {
1616

1717
validateMandatoryParams(url, token, toolId) {
1818
var errorMessage;
19-
if(!url) errorMessage = "URL is mandatory.";
20-
if(!token) errorMessage += "Token is mandatory.";
21-
if(!toolId) errorMessage += "ToolId is mandatory.";
19+
if(!url) errorMessage = "SNOW_URL is a required field.";
20+
if(!token) errorMessage += "SNOW_TOKEN is a required field.";
21+
if(!toolId) errorMessage += "SNOW_TOOLID is a required field.";
2222

2323
if(errorMessage) {
24-
errorMessage += " Please check GitLab project level environmental variables.";
24+
errorMessage += " Verify that the GitLab project level variables are configured.";
2525
console.error('\n \x1b[1m\x1b[31m' + errorMessage + '\x1b[0m\x1b[0m');
2626
process.exit(1);
2727
}

src/common/baseEnv.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = class BaseEnv{
1212
static CI_PAGES_URL = process.env.CI_PAGES_URL;
1313
static CI_PROJECT_TITLE = process.env.CI_PROJECT_TITLE;
1414
static CI_PROJECT_PATH = process.env.CI_PROJECT_PATH;
15+
static CI_PIPELINE_URL = process.env.CI_PROJECT_PATH;
1516
static CI_COMMIT_BRANCH = process.env.CI_COMMIT_BRANCH;
1617
static CI_API_V4_URL = process.env.CI_API_V4_URL;
1718
static CI_PIPELINE_SOURCE = process.env.CI_PIPELINE_SOURCE;

0 commit comments

Comments
 (0)