Skip to content

Commit b14df91

Browse files
Merge pull request #15 from ServiceNow/scratch/release_6.0.0
2 parents e75fff5 + db74c7d commit b14df91

File tree

6 files changed

+72
-71
lines changed

6 files changed

+72
-71
lines changed

README.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
New repository for developing a plugin to integrate between ITSM DevOps and GitLab pipelines
44

5+
56
# CLI example using npm modules
67

78
## Build and install
@@ -55,11 +56,11 @@ npm unlink .
5556
### Building Docker Image
5657

5758
```sh
58-
docker build -t servicenowdocker/sndevops:5.1.0 .
59+
docker build -t servicenowdocker/sndevops:6.0.0 .
5960
```
6061

6162
```sh
62-
docker push servicenowdocker/sndevops:5.1.0
63+
docker push servicenowdocker/sndevops:6.0.0
6364
```
6465

6566
## Integrating with GitLab
@@ -80,19 +81,19 @@ SNOW_TOOLID = <servicenow-tool-id>
8081

8182
### Additonal Env variables
8283
```
83-
CI_PIPELINE_ID: <pipeline-id>
84-
CI_API_V4_URL: <pipeline-url>
85-
CI_JOB_ID: <pipeline-execution-id>
86-
CI_PROJECT_PATH: <repository-path>
87-
CI_REPOSITORY_NAME: <repository-name>
88-
CI_RUN_ATTEMPT: <pipeline-attempt-number>
89-
CI_PROJECT_TITLE: <pipeline-name>
84+
PIPELINE_ID: <pipeline-id>
85+
API_V4_URL: <pipeline-url>
86+
JOB_ID: <pipeline-execution-id>
87+
PROJECT_PATH: <repository-path>
88+
REPOSITORY_NAME: <repository-name>
89+
RUN_ATTEMPT: <pipeline-attempt-number>
90+
PROJECT_TITLE: <pipeline-name>
9091
```
9192

9293
### Optional Env variables
9394
```
94-
CI_COMMIT_BRANCH: <commit-branch>
95-
CI_WORKFLOW_NAME: <workflow-name>
95+
COMMIT_BRANCH: <commit-branch>
96+
WORKFLOW_NAME: <workflow-name>
9697
```
9798

9899
**Example with passing all ServiceNow information via commandline**
@@ -105,10 +106,10 @@ stages:
105106

106107
package:
107108
stage: package
108-
image: servicenowdocker/sndevops:5.1.0
109+
image: servicenowdocker/sndevops:6.0.0
109110
script:
110-
- sndevopscli create artifact -a '[{"name":"artifact-name-$CI_JOB_ID","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
111-
- sndevopscli create package -n "package-name" -a '[{"name":"artifact-name-$CI_JOB_ID","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]
111+
- sndevopscli create artifact -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
112+
- sndevopscli create package -n "package-name" -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]
112113

113114
OR
114115

@@ -117,10 +118,10 @@ stages:
117118

118119
package:
119120
stage: package
120-
image: servicenowdocker/sndevops:5.1.0
121+
image: servicenowdocker/sndevops:6.0.0
121122
script:
122-
- 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"}]'
123-
- 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"}]
123+
- sndevopscli create artifact -u <servicenow-url> -t <tool-id> --token <tool-token> -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
124+
- sndevopscli create package -u <servicenow-url> -t <tool-id> --token <tool-token> -n "package-mame" -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]
124125

125126
-a : [mandatory]
126127
This specifies artifact details.
@@ -141,7 +142,7 @@ stages:
141142

142143
ServiceNow DevOps Change:
143144
stage: DevOpsChangeApproval
144-
image: servicenowdocker/sndevops:5.1.0
145+
image: servicenowdocker/sndevops:6.0.0
145146
script:
146147
- 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"}}'
147148

@@ -181,7 +182,7 @@ stages:
181182

182183
ServiceNow DevOps Sonar Scan Results:
183184
stage: DevOpsSonarStage
184-
image: servicenowdocker/sndevops:5.1.0
185+
image: servicenowdocker/sndevops:6.0.0
185186
script:
186187
- sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'xxxxxxx' -branch 'master'
187188

@@ -192,7 +193,7 @@ projectKey: [mandatory]
192193
This specifies the sonar project key.
193194

194195
branch: [optional]
195-
This specifies the branch on which the Sonar scan was executed. By default, it matches the branch for which the build was run. Note, for Harness, the branch option is required if CI_COMMIT_BRANCH is not provided.
196+
This specifies the branch on which the Sonar scan was executed. By default, it matches the branch for which the build was run. Note, for Harness, the branch option is required if COMMIT_BRANCH is not provided.
196197

197198
```
198199

@@ -206,15 +207,15 @@ stages:
206207

207208
ServiceNow DevOps Security Scan Results:
208209
stage: DevOpsSecurityScanStage
209-
image: servicenowdocker/sndevops:5.1.0
210+
image: servicenowdocker/sndevops:6.0.0
210211
script:
211-
- sndevopscli create securityScan -p "{\"pipelineInfo\":{\"buildNumber\":\"${CI_PIPELINE_ID}\",\"pipelineExecutionUrl\":\"${CI_PIPELINE_URL}\" },\"securityResultAttributes\":{ \"scanner\":\"Veracode\",\"applicationName\":\"PetStoreAPI-Github\",\"buildVersion\":\"\",\"securityToolId\":\"\"}}"
212+
- sndevopscli create securityScan -p "{\"pipelineInfo\":{\"buildNumber\":\"buildNumber\",\"pipelineExecutionUrl\":\"pipelineExecutionUrl\" },\"securityResultAttributes\":{ \"scanner\":\"Veracode\",\"applicationName\":\"PetStoreAPI-Github\",\"buildVersion\":\"\",\"securityToolId\":\"\"}}"
212213

213214

214215
-p: [mandatory]
215216
It the payload of security result attributes. The payload will have attributes as follows:
216-
buildNumber: CI_PIPELINE_ID (mandatory)
217-
pipelineExecutionUrl: CI_PIPELINE_URL (mandatory)
217+
buildNumber: This specifies ID of the Job (mandatory)
218+
pipelineExecutionUrl: This specifies the pipeline execution URL (mandatory)
218219
scanner: Scanning tool and is required e.g. Checkmarx One.
219220
projectName/projectId: Name/Id of your Checkmarx One project and is required. This attribute is applicable only for Checkmarx One.
220221
applicationName: Name of your Veracode application and is required. This attribute is applicable only for Veracode.
@@ -234,11 +235,11 @@ stages:
234235

235236
ServiceNow DevOps Get Change:
236237
stage: DevOpsGetChange
237-
image: servicenowdocker/sndevops:5.1.0
238+
image: servicenowdocker/sndevops:6.0.0
238239
script:
239-
- sndevopscli get change -p "{\"buildNumber\":${CHG_JOB_ID},\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"GitlabDockerGetAndUpdateChange\"}"
240+
- sndevopscli get change -p "{\"buildNumber\":\"buildNumber\",\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"GitlabDockerGetAndUpdateChange\"}"
240241

241-
-p: It stands for changeDetails. The change details to be used for identifying change request in ServiceNow instance. The change details is a JSON object surrounded by curly braces {} containing key-value pair separated by a comma ,. A key-value pair consists of a key and a value separated by a colon :. The keys supported in key-value pair are buildNumber, pipelineName, stageName
242+
-p: It stands for changeDetails. The change details to be used for identifying change request in ServiceNow instance. The change details is a JSON object surrounded by curly braces {} containing key-value pair separated by a comma ,. A key-value pair consists of a key and a value separated by a colon :. The keys supported in key-value pair are buildNumber, pipelineName, stageName. All fields in the Change Request table are supported except risk, impact and risk_impact_analysis. For more information, [see documentation](https://docs.servicenow.com/bundle/vancouver-it-service-management/page/product/enterprise-dev-ops/concept/dev-ops-config-change-details.html).
242243

243244
buildNumber: [mandatory]
244245
This specifies ID of the Job where we have created change request.
@@ -270,7 +271,7 @@ stages:
270271

271272
ServiceNow DevOps Update Change:
272273
stage: DevOpsUpdateChangeStage
273-
image: servicenowdocker/sndevops:5.1.0
274+
image: servicenowdocker/sndevops:6.0.0
274275
script:
275276
- sndevopscli update change -n 'CHGXXXXXX' -p "{\"short_description\":\"Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXX\",\"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\"}"
276277

@@ -297,7 +298,7 @@ stages:
297298

298299
ServiceNow DevOps Change Step:
299300
stage: changeapproval
300-
image: servicenowdocker/sndevops:5.1.0
301+
image: servicenowdocker/sndevops:6.0.0
301302
script:
302303
- sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxxx\",\"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\"}}"
303304

github-ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ env:
1313
SNOW_TOKEN: ${{ secrets.SNOW_TOKEN }}
1414
SNOW_TOOLID: ${{ secrets.SNOW_TOOLID }}
1515
# These are the optional env variables
16-
#CI_PIPELINE_ID: ${{ github.run_id }}
17-
#CI_API_V4_URL: ${{ github.server_url }}
18-
#CI_JOB_ID: ${{ github.run_id }}
19-
#CI_PROJECT_PATH: ${{ github.job }}
20-
#CI_REPOSITORY_NAME: ${{ github.repository }}
21-
#CI_RUN_ATTEMPT: ${{ github.run_attempt }}
22-
#CI_PROJECT_TITLE: ${{ github.repository }}/${{github.workflow}}
23-
#CI_COMMIT_BRANCH: ${{ github.ref_name }}
24-
#CI_WORKFLOW_NAME: ${{ github.workflow }}
16+
#PIPELINE_ID: ${{ github.run_id }}
17+
#API_V4_URL: ${{ github.server_url }}
18+
#JOB_ID: ${{ github.run_id }}
19+
#PROJECT_PATH: ${{ github.job }}
20+
#REPOSITORY_NAME: ${{ github.repository }}
21+
#RUN_ATTEMPT: ${{ github.run_attempt }}
22+
#PROJECT_TITLE: ${{ github.repository }}/${{github.workflow}}
23+
#COMMIT_BRANCH: ${{ github.ref_name }}
24+
#WORKFLOW_NAME: ${{ github.workflow }}
2525

2626
jobs:
2727
build:
@@ -35,7 +35,7 @@ jobs:
3535
runs-on: ubuntu-latest
3636
needs: build
3737
container:
38-
image: servicenowdocker/sndevops:5.1.0
38+
image: servicenowdocker/sndevops:6.0.0
3939
env:
4040
CI_JOB_NAME: "ServiceNowDevOpsChange"
4141

@@ -48,7 +48,7 @@ jobs:
4848
runs-on: ubuntu-latest
4949
needs: ServiceNowDevOpsChange
5050
container:
51-
image: servicenowdocker/sndevops:5.1.0
51+
image: servicenowdocker/sndevops:6.0.0
5252
env:
5353
CI_JOB_NAME: "ServiceNowDevOpsChange"
5454

@@ -61,7 +61,7 @@ jobs:
6161
runs-on: ubuntu-latest
6262
needs: build
6363
container:
64-
image: servicenowdocker/sndevops:5.1.0
64+
image: servicenowdocker/sndevops:6.0.0
6565
env:
6666
CI_JOB_NAME: "ArtifactAndPackage"
6767
steps:
@@ -75,7 +75,7 @@ jobs:
7575
needs: ArtifactAndPackage
7676
runs-on: ubuntu-latest
7777
container:
78-
image: servicenowdocker/sndevops:5.1.0
78+
image: servicenowdocker/sndevops:6.0.0
7979
env:
8080
CI_JOB_NAME: "ServiceNowDevOpsSonarScanResults"
8181
steps:
@@ -88,7 +88,7 @@ jobs:
8888
runs-on: ubuntu-latest
8989
needs: build
9090
container:
91-
image: servicenowdocker/sndevops:5.1.0
91+
image: servicenowdocker/sndevops:6.0.0
9292
steps:
9393
- name: security scan
9494
run: |

gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: servicenowdocker/sndevops:5.1.0
1+
image: servicenowdocker/sndevops:6.0.0
22
stages:
33
- pre-build
44
- build

harness-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ pipeline:
4545
identifier: Sonar_container
4646
spec:
4747
connectorRef: docker_connector # harness docker connector
48-
image: servicenowdocker/sndevops:5.1.0
48+
image: servicenowdocker/sndevops:6.0.0
4949
command: |-
5050
export SNOW_URL="<+variable.SNOW_URL>"
5151
export SNOW_TOOLID="<+variable.SNOW_TOOLID>"
5252
export SNOW_TOKEN="<+variable.SNOW_TOKEN>"
5353
export HARNESS_STAGE_NAME="<+stage.identifier>"
5454
export HARNESS_PIPELINE_NAME="<+org.identifier>/<+project.identifier>/<+pipeline.name>"
55-
export CI_COMMIT_BRANCH="main"
55+
export COMMIT_BRANCH="main"
5656
sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'SONAR_PROJECT_KEY' -branch "main"
5757
shell: Sh
5858
infrastructure:
@@ -93,7 +93,7 @@ pipeline:
9393
identifier: security
9494
spec:
9595
connectorRef: docker_connector # harness docker connector
96-
image: servicenowdocker/sndevops:5.1.0
96+
image: servicenowdocker/sndevops:6.0.0
9797
command: |-
9898
export SNOW_URL="<+variable.SNOW_URL>"
9999
export SNOW_TOOLID="<+variable.SNOW_TOOLID>"
@@ -156,7 +156,7 @@ pipeline:
156156
identifier: ServiceNow_change
157157
spec:
158158
connectorRef: docker_connector # harness docker connector
159-
image: servicenowdocker/sndevops:5.1.0
159+
image: servicenowdocker/sndevops:6.0.0
160160
command: |-
161161
# set mandetory variables. These can be set from Environment variable section of Optional configuration as well.
162162
export HARNESS_STAGE_NAME="<+stage.identifier>"

src/common/baseEnv.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ const ToolHandlerRegistry = require("../handler/registry");
33

44
module.exports = class BaseEnv{
55

6-
static CI_PROJECT_NAME = process.env.CI_PROJECT_NAME;
7-
static CI_JOB_STAGE = process.env.CI_JOB_STAGE;
8-
static CI_JOB_ID = process.env.CI_JOB_ID;
9-
static CI_SERVER_URL = process.env.CI_SERVER_URL;
10-
static CI_COMMIT_SHA = process.env.CI_COMMIT_SHA
11-
static CI_JOB_NAME = process.env.CI_JOB_NAME
12-
static CI_PIPELINE_ID = process.env.CI_PIPELINE_ID
13-
static CI_PAGES_URL = process.env.CI_PAGES_URL;
14-
static CI_PROJECT_TITLE = process.env.CI_PROJECT_TITLE;
15-
static CI_PROJECT_PATH = process.env.CI_PROJECT_PATH;
16-
static CI_PIPELINE_URL = process.env.CI_PROJECT_PATH;
17-
static CI_COMMIT_BRANCH = process.env.CI_COMMIT_BRANCH;
18-
static CI_API_V4_URL = process.env.CI_API_V4_URL;
19-
static CI_PIPELINE_SOURCE = process.env.CI_PIPELINE_SOURCE;
20-
static CI_PROJECT_ID = process.env.CI_PROJECT_ID;
6+
static CI_PROJECT_NAME = process.env.CI_PROJECT_NAME || process.env.PROJECT_NAME;
7+
static CI_JOB_STAGE = process.env.CI_JOB_STAGE || process.env.JOB_STAGE;
8+
static CI_JOB_ID = process.env.CI_JOB_ID || process.env.JOB_ID;
9+
static CI_SERVER_URL = process.env.CI_SERVER_URL || process.env.SERVER_URL;
10+
static CI_COMMIT_SHA = process.env.CI_COMMIT_SHA || process.env.COMMIT_SHA;
11+
static CI_JOB_NAME = process.env.CI_JOB_NAME || process.env.JOB_NAME;
12+
static CI_PIPELINE_ID = process.env.CI_PIPELINE_ID || process.env.PIPELINE_ID;
13+
static CI_PAGES_URL = process.env.CI_PAGES_URL || process.env.PAGES_URL;
14+
static CI_PROJECT_TITLE = process.env.CI_PROJECT_TITLE || process.env.PROJECT_TITLE;
15+
static CI_PROJECT_PATH = process.env.CI_PROJECT_PATH || process.env.PROJECT_PATH;
16+
static CI_PIPELINE_URL = process.env.CI_PROJECT_PATH || process.env.PROJECT_PATH;
17+
static CI_COMMIT_BRANCH = process.env.CI_COMMIT_BRANCH || process.env.COMMIT_BRANCH;
18+
static CI_API_V4_URL = process.env.CI_API_V4_URL || process.env.API_V4_URL;
19+
static CI_PIPELINE_SOURCE = process.env.CI_PIPELINE_SOURCE || process.env.PIPELINE_SOURCE;
20+
static CI_PROJECT_ID = process.env.CI_PROJECT_ID || process.env.PROJECT_ID;
2121
static SNOW_URL = process.env.SNOW_URL;
2222
static SNOW_TOKEN = process.env.SNOW_TOKEN;
2323
static SNOW_TOOLID = process.env.SNOW_TOOLID;
24-
static CI_DEFAULT_BRANCH = process.env.CI_DEFAULT_BRANCH;
25-
static CI_MERGE_REQUEST_SOURCE_BRANCH_NAME = process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME;
24+
static CI_DEFAULT_BRANCH = process.env.CI_DEFAULT_BRANCH || process.env.DEFAULT_BRANCH;
25+
static CI_MERGE_REQUEST_SOURCE_BRANCH_NAME = process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME || process.env.MERGE_REQUEST_SOURCE_BRANCH_NAME;
2626

27-
static CI_RUN_ATTEMPT = process.env.CI_RUN_ATTEMPT;
28-
static CI_REPOSITORY_NAME = process.env.CI_REPOSITORY_NAME;
29-
static CI_CALLBACK_URL = process.env.CI_CALLBACK_URL;
30-
static CI_WORKFLOW_NAME = process.env.CI_WORKFLOW_NAME;
27+
static CI_RUN_ATTEMPT = process.env.RUN_ATTEMPT;
28+
static CI_REPOSITORY_NAME = process.env.REPOSITORY_NAME;
29+
static CI_CALLBACK_URL = process.env.CALLBACK_URL;
30+
static CI_WORKFLOW_NAME = process.env.WORKFLOW_NAME;
3131

3232
static getEnv(envVariableName){
3333
return process.env[envVariableName];

src/handler/harness.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HarnessIntegrationHandler extends AbstractToolIntegrationHandler {
2525
}
2626

2727
getBranch () {
28-
return process.env.CI_COMMIT_BRANCH
28+
return process.env.COMMIT_BRANCH
2929
}
3030

3131
getProjectTitle () {
@@ -47,7 +47,7 @@ class HarnessIntegrationHandler extends AbstractToolIntegrationHandler {
4747
getCallbackURL (){
4848
const HARNESS_DEFAULT_URL = 'https://app.harness.io/';
4949
const harnessPipelineExecutionUrl = `${HARNESS_DEFAULT_URL}/ng/#/account/${process.env.HARNESS_ACCOUNT_ID}/ci/orgs/${process.env.HARNESS_ORG_ID}/projects/${process.env.HARNESS_PROJECT_ID}/pipeline/${process.env.HARNESS_PIPELINE_ID}/executions/${process.env.HARNESS_EXECUTION_ID}`;
50-
return process.env.CI_CALLBACK_URL || harnessPipelineExecutionUrl;
50+
return process.env.CALLBACK_URL || harnessPipelineExecutionUrl;
5151
}
5252

5353
getPipelineName (pipelineName) {

0 commit comments

Comments
 (0)