Skip to content

Commit 0a4001b

Browse files
Releasing 6.0.0 version
1 parent e75fff5 commit 0a4001b

File tree

6 files changed

+82
-72
lines changed

6 files changed

+82
-72
lines changed

README.md

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
# app-devops-gitlab-docker
1+
# app-devops-gitlab
22

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

5+
### Owners
6+
7+
> ramachandrarao.p
8+
9+
### How to build on Jenkins
10+
* Create a `pom.xml` file at the root level
11+
* Go to the [BT1 Service Catalog](https://buildtools1.service-now.com/nav_to.do?uri=%2Fcom.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D9dbd0c54db1acb403a3d5dd5ce961948%26sysparm_link_parent%3Dad2fecb72bfc310052f7c71317da157e%26sysparm_catalog%3De0d08b13c3330100c8b837659bba8fb4%26sysparm_catalog_view%3Dess%26sysparm_view%3Dess) to request a Jenkins job
12+
13+
Once the request is processed, a multi-branch job is created on https://buildmaster-hotel.devsnc.com and will build any branches that match [ServiceNow branch naming convention](https://buildtools1.service-now.com/kb_view_customer.do?sysparm_article=KB0528607).
14+
515
# CLI example using npm modules
616

717
## Build and install
@@ -55,11 +65,11 @@ npm unlink .
5565
### Building Docker Image
5666

5767
```sh
58-
docker build -t servicenowdocker/sndevops:5.1.0 .
68+
docker build -t servicenowdocker/sndevops:6.0.0 .
5969
```
6070

6171
```sh
62-
docker push servicenowdocker/sndevops:5.1.0
72+
docker push servicenowdocker/sndevops:6.0.0
6373
```
6474

6575
## Integrating with GitLab
@@ -80,19 +90,19 @@ SNOW_TOOLID = <servicenow-tool-id>
8090

8191
### Additonal Env variables
8292
```
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>
93+
PIPELINE_ID: <pipeline-id>
94+
API_V4_URL: <pipeline-url>
95+
JOB_ID: <pipeline-execution-id>
96+
PROJECT_PATH: <repository-path>
97+
REPOSITORY_NAME: <repository-name>
98+
RUN_ATTEMPT: <pipeline-attempt-number>
99+
PROJECT_TITLE: <pipeline-name>
90100
```
91101

92102
### Optional Env variables
93103
```
94-
CI_COMMIT_BRANCH: <commit-branch>
95-
CI_WORKFLOW_NAME: <workflow-name>
104+
COMMIT_BRANCH: <commit-branch>
105+
WORKFLOW_NAME: <workflow-name>
96106
```
97107

98108
**Example with passing all ServiceNow information via commandline**
@@ -105,10 +115,10 @@ stages:
105115

106116
package:
107117
stage: package
108-
image: servicenowdocker/sndevops:5.1.0
118+
image: servicenowdocker/sndevops:6.0.0
109119
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"}]
120+
- sndevopscli create artifact -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
121+
- sndevopscli create package -n "package-name" -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]
112122

113123
OR
114124

@@ -117,10 +127,10 @@ stages:
117127

118128
package:
119129
stage: package
120-
image: servicenowdocker/sndevops:5.1.0
130+
image: servicenowdocker/sndevops:6.0.0
121131
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"}]
132+
- sndevopscli create artifact -u <servicenow-url> -t <tool-id> --token <tool-token> -a '[{"name":"artifact-name","repositoryName":"artifact-repo-name" ,"version":"1.3.0"}]'
133+
- 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"}]
124134

125135
-a : [mandatory]
126136
This specifies artifact details.
@@ -141,7 +151,7 @@ stages:
141151

142152
ServiceNow DevOps Change:
143153
stage: DevOpsChangeApproval
144-
image: servicenowdocker/sndevops:5.1.0
154+
image: servicenowdocker/sndevops:6.0.0
145155
script:
146156
- 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"}}'
147157

@@ -181,7 +191,7 @@ stages:
181191

182192
ServiceNow DevOps Sonar Scan Results:
183193
stage: DevOpsSonarStage
184-
image: servicenowdocker/sndevops:5.1.0
194+
image: servicenowdocker/sndevops:6.0.0
185195
script:
186196
- sndevopscli create sonar -url 'https://sonarcloud.io' -projectKey 'xxxxxxx' -branch 'master'
187197

@@ -192,7 +202,7 @@ projectKey: [mandatory]
192202
This specifies the sonar project key.
193203

194204
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.
205+
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.
196206

197207
```
198208

@@ -206,15 +216,15 @@ stages:
206216

207217
ServiceNow DevOps Security Scan Results:
208218
stage: DevOpsSecurityScanStage
209-
image: servicenowdocker/sndevops:5.1.0
219+
image: servicenowdocker/sndevops:6.0.0
210220
script:
211-
- sndevopscli create securityScan -p "{\"pipelineInfo\":{\"buildNumber\":\"${CI_PIPELINE_ID}\",\"pipelineExecutionUrl\":\"${CI_PIPELINE_URL}\" },\"securityResultAttributes\":{ \"scanner\":\"Veracode\",\"applicationName\":\"PetStoreAPI-Github\",\"buildVersion\":\"\",\"securityToolId\":\"\"}}"
221+
- sndevopscli create securityScan -p "{\"pipelineInfo\":{\"buildNumber\":\"buildNumber\",\"pipelineExecutionUrl\":\"pipelineExecutionUrl\" },\"securityResultAttributes\":{ \"scanner\":\"Veracode\",\"applicationName\":\"PetStoreAPI-Github\",\"buildVersion\":\"\",\"securityToolId\":\"\"}}"
212222

213223

214224
-p: [mandatory]
215225
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)
226+
buildNumber: This specifies ID of the Job (mandatory)
227+
pipelineExecutionUrl: This specifies the pipeline execution URL (mandatory)
218228
scanner: Scanning tool and is required e.g. Checkmarx One.
219229
projectName/projectId: Name/Id of your Checkmarx One project and is required. This attribute is applicable only for Checkmarx One.
220230
applicationName: Name of your Veracode application and is required. This attribute is applicable only for Veracode.
@@ -234,11 +244,11 @@ stages:
234244

235245
ServiceNow DevOps Get Change:
236246
stage: DevOpsGetChange
237-
image: servicenowdocker/sndevops:5.1.0
247+
image: servicenowdocker/sndevops:6.0.0
238248
script:
239-
- sndevopscli get change -p "{\"buildNumber\":${CHG_JOB_ID},\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"GitlabDockerGetAndUpdateChange\"}"
249+
- sndevopscli get change -p "{\"buildNumber\":\"buildNumber\",\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"GitlabDockerGetAndUpdateChange\"}"
240250

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
251+
-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).
242252

243253
buildNumber: [mandatory]
244254
This specifies ID of the Job where we have created change request.
@@ -270,7 +280,7 @@ stages:
270280

271281
ServiceNow DevOps Update Change:
272282
stage: DevOpsUpdateChangeStage
273-
image: servicenowdocker/sndevops:5.1.0
283+
image: servicenowdocker/sndevops:6.0.0
274284
script:
275285
- 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\"}"
276286

@@ -297,7 +307,7 @@ stages:
297307

298308
ServiceNow DevOps Change Step:
299309
stage: changeapproval
300-
image: servicenowdocker/sndevops:5.1.0
310+
image: servicenowdocker/sndevops:6.0.0
301311
script:
302312
- 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\"}}"
303313

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)