@sonisoft/now-sdk-ext-cli 1.1.0-alpha.3 โ 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1825 -34
- package/dist/commands/app/index.d.ts +4 -1
- package/dist/commands/app/index.d.ts.map +1 -1
- package/dist/commands/app/index.js +25 -4
- package/dist/commands/app/index.js.map +1 -1
- package/dist/commands/app/install.d.ts +4 -1
- package/dist/commands/app/install.d.ts.map +1 -1
- package/dist/commands/app/install.js +40 -6
- package/dist/commands/app/install.js.map +1 -1
- package/dist/commands/app/repo-install.d.ts +19 -0
- package/dist/commands/app/repo-install.d.ts.map +1 -0
- package/dist/commands/app/repo-install.js +173 -0
- package/dist/commands/app/repo-install.js.map +1 -0
- package/dist/commands/app/repo-list.d.ts +17 -0
- package/dist/commands/app/repo-list.d.ts.map +1 -0
- package/dist/commands/app/repo-list.js +152 -0
- package/dist/commands/app/repo-list.js.map +1 -0
- package/dist/commands/app/uninstall.d.ts +16 -0
- package/dist/commands/app/uninstall.d.ts.map +1 -0
- package/dist/commands/app/uninstall.js +70 -0
- package/dist/commands/app/uninstall.js.map +1 -0
- package/dist/commands/atf/index.d.ts +71 -0
- package/dist/commands/atf/index.d.ts.map +1 -0
- package/dist/commands/atf/index.js +256 -0
- package/dist/commands/atf/index.js.map +1 -0
- package/dist/commands/exec/index.d.ts +17 -3
- package/dist/commands/exec/index.d.ts.map +1 -1
- package/dist/commands/exec/index.js +286 -26
- package/dist/commands/exec/index.js.map +1 -1
- package/dist/commands/log/index.d.ts +46 -0
- package/dist/commands/log/index.d.ts.map +1 -0
- package/dist/commands/log/index.js +418 -0
- package/dist/commands/log/index.js.map +1 -0
- package/dist/common/authenticated-command.js +2 -2
- package/dist/common/authenticated-command.js.map +1 -1
- package/dist/common/scope-autocomplete.d.ts +20 -0
- package/dist/common/scope-autocomplete.d.ts.map +1 -0
- package/dist/common/scope-autocomplete.js +94 -0
- package/dist/common/scope-autocomplete.js.map +1 -0
- package/oclif.manifest.json +691 -12
- package/package.json +31 -12
package/README.md
CHANGED
|
@@ -1,27 +1,411 @@
|
|
|
1
|
-
@sonisoft/now-sdk-ext-cli
|
|
2
|
-
|
|
1
|
+
# @sonisoft/now-sdk-ext-cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@sonisoft/now-sdk-ext-cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
> A powerful CLI toolkit that extends the ServiceNow SDK with advanced automation capabilities for development, testing, and operations.
|
|
7
|
+
|
|
8
|
+
## ๐ Overview
|
|
9
|
+
|
|
10
|
+
`now-sdk-ext-cli` (command: `nex`) is a comprehensive command-line interface that enhances the official ServiceNow SDK with powerful features for developers and administrators. It provides seamless integration with ServiceNow instances to automate common tasks, execute tests, manage applications, and run scripts remotely.
|
|
11
|
+
|
|
12
|
+
### Why Use `nex`?
|
|
13
|
+
|
|
14
|
+
- **๐ช Powerful Automation**: Automate ServiceNow operations that would otherwise require manual UI interaction
|
|
15
|
+
- **โก Fast Development**: Interactive REPL mode for rapid script development and testing
|
|
16
|
+
- **๐ง DevOps Ready**: Built for CI/CD with JSON output, exit codes, and scriptable operations
|
|
17
|
+
- **๐ฏ Developer Friendly**: Intuitive commands, autocomplete, and extensive documentation
|
|
18
|
+
- **๐ Secure**: Uses ServiceNow SDK's secure keychain storage for credentials
|
|
19
|
+
|
|
20
|
+
### Key Features
|
|
21
|
+
|
|
22
|
+
#### ๐งช ATF Test Automation
|
|
23
|
+
Execute individual ATF tests or entire test suites with detailed results, perfect for CI/CD pipelines.
|
|
24
|
+
|
|
25
|
+
#### ๐ฆ Application Lifecycle Management
|
|
26
|
+
- **Install** applications from batch definitions
|
|
27
|
+
- **Uninstall** applications programmatically
|
|
28
|
+
- **Repository Management**: List and install apps from your company repository
|
|
29
|
+
- Automated deployment workflows
|
|
30
|
+
|
|
31
|
+
#### โก Script Execution (Enhanced)
|
|
32
|
+
- **File Mode**: Execute JavaScript files on ServiceNow instances
|
|
33
|
+
- **REPL Mode**: Interactive script executor (like node REPL, but for ServiceNow!)
|
|
34
|
+
- **Parameterization**: Template scripts with `{placeholder}` replacement
|
|
35
|
+
- **Scope-Aware**: Execute in global or custom application scopes
|
|
36
|
+
|
|
37
|
+
#### ๐จ Advanced Features
|
|
38
|
+
- **Dynamic Autocomplete**: Tab completion that queries your ServiceNow instance for scopes
|
|
39
|
+
- **Batch Operations**: Install multiple applications from JSON definitions
|
|
40
|
+
- **Progress Monitoring**: Real-time progress for long-running operations
|
|
41
|
+
- **JSON Output**: Perfect for parsing and automation
|
|
42
|
+
|
|
43
|
+
#### ๐ CI/CD Integration
|
|
44
|
+
- Proper exit codes (0 = success, 1 = failure)
|
|
45
|
+
- JSON output mode for all commands
|
|
46
|
+
- Environment variable support
|
|
47
|
+
- Scriptable and automatable
|
|
48
|
+
|
|
49
|
+
## ๐ Table of Contents
|
|
50
|
+
|
|
51
|
+
- [Installation](#-installation)
|
|
52
|
+
- [Prerequisites](#-prerequisites)
|
|
53
|
+
- [Quick Start](#-quick-start)
|
|
54
|
+
- [Core Capabilities](#-core-capabilities)
|
|
55
|
+
- [ATF Testing](#atf-testing)
|
|
56
|
+
- [Application Management](#application-management)
|
|
57
|
+
- [Script Execution with REPL](#script-execution-with-repl)
|
|
58
|
+
- [Company Repository](#company-repository-integration)
|
|
59
|
+
- [All Commands](#-commands)
|
|
60
|
+
- [Authentication](#-authentication)
|
|
61
|
+
- [Advanced Features](#-advanced-features)
|
|
62
|
+
- [Interactive REPL](#interactive-repl-mode)
|
|
63
|
+
- [Script Parameterization](#script-parameterization)
|
|
64
|
+
- [Shell Autocomplete](#shell-autocomplete)
|
|
65
|
+
- [CI/CD Integration](#-cicd-integration)
|
|
66
|
+
- [Examples](#-examples)
|
|
67
|
+
- [Troubleshooting](#-troubleshooting)
|
|
68
|
+
- [Documentation](#-documentation)
|
|
69
|
+
- [Support & Contributing](#-support--contributing)
|
|
70
|
+
|
|
71
|
+
## ๐พ Installation
|
|
72
|
+
|
|
73
|
+
### Global Installation (Recommended)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm install -g @sonisoft/now-sdk-ext-cli
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Local Installation
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm install @sonisoft/now-sdk-ext-cli
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Verify Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
nex --version
|
|
89
|
+
nex --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## ๐ Prerequisites
|
|
93
|
+
|
|
94
|
+
### ServiceNow SDK
|
|
95
|
+
|
|
96
|
+
**Required**: This CLI extension leverages the official ServiceNow SDK for authentication management. You must install and configure the ServiceNow SDK first.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install -g @servicenow/sdk
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Verify installation:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
now-sdk --version
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Important**: The `now-sdk-ext-cli` does not manage credentials directly. It uses authentication credentials configured via the ServiceNow SDK (`now-sdk auth` command). This provides:
|
|
109
|
+
- Secure credential storage in your system's keychain
|
|
110
|
+
- Centralized authentication management across ServiceNow tools
|
|
111
|
+
- Support for multiple instance profiles
|
|
112
|
+
- OAuth and basic authentication methods
|
|
113
|
+
|
|
114
|
+
### Node.js
|
|
115
|
+
|
|
116
|
+
- **Minimum Version**: Node.js 18.0.0 or higher
|
|
117
|
+
- **Recommended**: Node.js 20.x or later
|
|
118
|
+
|
|
119
|
+
### ServiceNow Instance
|
|
120
|
+
|
|
121
|
+
- ServiceNow instance with appropriate permissions
|
|
122
|
+
- API access enabled
|
|
123
|
+
- User account with required roles:
|
|
124
|
+
- `admin` or `atf_test_runner` for ATF operations
|
|
125
|
+
- `admin` or `sn_cicd.sys_ci_automation` for application management
|
|
126
|
+
- Script execution requires appropriate scope access
|
|
127
|
+
|
|
128
|
+
## ๐ฏ Quick Start
|
|
129
|
+
|
|
130
|
+
### 1. Configure Authentication
|
|
131
|
+
|
|
132
|
+
First, set up your ServiceNow instance credentials using the ServiceNow SDK:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Add credentials (interactive - will prompt for username/password)
|
|
136
|
+
now-sdk auth --add your-instance.service-now.com --type basic --alias my-dev-instance
|
|
137
|
+
|
|
138
|
+
# Set as default (optional)
|
|
139
|
+
now-sdk auth --use my-dev-instance
|
|
140
|
+
|
|
141
|
+
# List configured authentication profiles
|
|
142
|
+
now-sdk auth --list
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Note**: Credentials configured via `now-sdk auth` are automatically available to `nex` commands through the `--auth` flag.
|
|
146
|
+
|
|
147
|
+
### 2. Run Your First Command
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Start interactive REPL
|
|
151
|
+
nex exec global --auth my-dev-instance
|
|
152
|
+
|
|
153
|
+
# Execute an ATF test
|
|
154
|
+
nex atf --test-id <test-sys-id> --auth my-dev-instance
|
|
155
|
+
|
|
156
|
+
# List repository applications
|
|
157
|
+
nex app:repo-list --auth my-dev-instance
|
|
3
158
|
|
|
4
|
-
|
|
159
|
+
# Install from repository
|
|
160
|
+
nex app:repo-install --scope x_my_app --auth my-dev-instance
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## ๐ฏ Core Capabilities
|
|
166
|
+
|
|
167
|
+
### ATF Testing
|
|
168
|
+
|
|
169
|
+
Execute Automated Test Framework tests and suites directly from the command line.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Execute a single test
|
|
173
|
+
nex atf --test-id f717a8c783103210621e78c6feaad396 --auth dev
|
|
174
|
+
|
|
175
|
+
# Execute a test suite by ID
|
|
176
|
+
nex atf --suite-id e077e00b83103210621e78c6feaad383 --auth dev --wait
|
|
177
|
+
|
|
178
|
+
# Execute by name with JSON output (perfect for CI/CD)
|
|
179
|
+
nex atf --suite-name "Smoke Tests" --auth dev --json > results.json
|
|
180
|
+
|
|
181
|
+
# Configure browser and performance settings
|
|
182
|
+
nex atf --suite-id abc123 --browser chrome --performance --auth dev
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Key Features:**
|
|
186
|
+
- Execute individual tests or complete suites
|
|
187
|
+
- Wait for completion or run async
|
|
188
|
+
- JSON output for CI/CD integration
|
|
189
|
+
- Browser/OS configuration
|
|
190
|
+
- Performance testing mode
|
|
191
|
+
- Real-time progress monitoring
|
|
192
|
+
|
|
193
|
+
### Application Management
|
|
194
|
+
|
|
195
|
+
Comprehensive application lifecycle management tools.
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Install applications from batch definition
|
|
199
|
+
nex app:install --batch --definitionPath ./apps.json --auth dev
|
|
200
|
+
|
|
201
|
+
# Uninstall an application
|
|
202
|
+
nex app:uninstall -i <sys_id> -s x_my_app --auth dev
|
|
203
|
+
|
|
204
|
+
# List repository applications (what's available to install)
|
|
205
|
+
nex app:repo-list --installable --auth dev
|
|
206
|
+
|
|
207
|
+
# Install from company repository
|
|
208
|
+
nex app:repo-install --scope x_my_app --version 2.1.0 --auth dev
|
|
209
|
+
|
|
210
|
+
# List installed repository apps
|
|
211
|
+
nex app:repo-list --installed --json --auth dev
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Key Features:**
|
|
215
|
+
- Batch installation from JSON definitions
|
|
216
|
+
- Repository browsing and installation
|
|
217
|
+
- Progress monitoring with configurable timeouts
|
|
218
|
+
- Post-installation verification
|
|
219
|
+
- JSON output for automation
|
|
220
|
+
|
|
221
|
+
### Script Execution with REPL
|
|
222
|
+
|
|
223
|
+
Execute JavaScript on ServiceNow instances - now with three powerful modes!
|
|
224
|
+
|
|
225
|
+
#### Mode 1: Execute Script Files
|
|
226
|
+
```bash
|
|
227
|
+
nex exec global ./cleanup.js --auth dev
|
|
228
|
+
nex exec x_my_app ./app-config.js --auth dev
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### Mode 2: Interactive REPL โญ NEW!
|
|
232
|
+
```bash
|
|
233
|
+
$ nex exec global --auth dev
|
|
234
|
+
|
|
235
|
+
sn> var gr = new GlideRecord('sys_user');
|
|
236
|
+
... gr.addQuery('active', true);
|
|
237
|
+
... gr.query();
|
|
238
|
+
... gs.info('Active users: ' + gr.getRowCount());
|
|
239
|
+
... .exec
|
|
240
|
+
|
|
241
|
+
*** Script: Active users: 142
|
|
242
|
+
|
|
243
|
+
sn> .exit
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**REPL Features:**
|
|
247
|
+
- Multi-line script input
|
|
248
|
+
- Execute with `.exec` or Ctrl+D
|
|
249
|
+
- Clear buffer with `.clear`
|
|
250
|
+
- Command history within session
|
|
251
|
+
- Beautiful, intuitive interface
|
|
252
|
+
|
|
253
|
+
#### Mode 3: Parameterized Scripts โญ NEW!
|
|
254
|
+
```bash
|
|
255
|
+
# Script with placeholders: {username}, {table}
|
|
256
|
+
nex exec global ./query-user.js \
|
|
257
|
+
--auth dev \
|
|
258
|
+
--params '{"username":"admin","table":"sys_user"}'
|
|
259
|
+
```
|
|
5
260
|
|
|
6
|
-
|
|
7
|
-
|
|
261
|
+
**Parameterization Features:**
|
|
262
|
+
- `{placeholder}` syntax in scripts
|
|
263
|
+
- JSON parameter object
|
|
264
|
+
- Multiple parameters supported
|
|
265
|
+
- All data types (string, number, boolean)
|
|
266
|
+
- Perfect for environment-specific scripts
|
|
8
267
|
|
|
9
|
-
|
|
10
|
-
to the command(s) below.
|
|
268
|
+
### Company Repository Integration
|
|
11
269
|
|
|
12
|
-
|
|
13
|
-
You will need to install the SDK globally separately in order to use the now-sdk command.
|
|
270
|
+
Discover and install applications from your company's internal repository.
|
|
14
271
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-- Future work of this CLI is intended to overcome this issue.
|
|
272
|
+
```bash
|
|
273
|
+
# See what's available
|
|
274
|
+
nex app:repo-list --auth prod
|
|
19
275
|
|
|
276
|
+
# Filter for installable apps
|
|
277
|
+
nex app:repo-list --installable --json --auth prod
|
|
278
|
+
|
|
279
|
+
# Install by scope (automatic lookup)
|
|
280
|
+
nex app:repo-install --scope x_custom_app --auth prod
|
|
281
|
+
|
|
282
|
+
# Install specific version
|
|
283
|
+
nex app:repo-install --scope x_custom_app --version 1.2.0 --auth prod
|
|
284
|
+
|
|
285
|
+
# Background installation
|
|
286
|
+
nex app:repo-install --scope x_custom_app --no-wait --auth prod
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Key Features:**
|
|
290
|
+
- Browse company repository applications
|
|
291
|
+
- Filter by installation status
|
|
292
|
+
- Install by scope name (no need to look up sys_id)
|
|
293
|
+
- Version control
|
|
294
|
+
- Wait for completion or run async
|
|
295
|
+
- Post-installation verification
|
|
296
|
+
|
|
297
|
+
## ๐ Commands
|
|
20
298
|
|
|
21
299
|
<!-- toc -->
|
|
300
|
+
* [@sonisoft/now-sdk-ext-cli](#sonisoftnow-sdk-ext-cli)
|
|
301
|
+
* [Add credentials (interactive - will prompt for username/password)](#add-credentials-interactive---will-prompt-for-usernamepassword)
|
|
302
|
+
* [Set as default (optional)](#set-as-default-optional)
|
|
303
|
+
* [List configured authentication profiles](#list-configured-authentication-profiles)
|
|
304
|
+
* [Start interactive REPL](#start-interactive-repl)
|
|
305
|
+
* [Execute an ATF test](#execute-an-atf-test)
|
|
306
|
+
* [List repository applications](#list-repository-applications)
|
|
307
|
+
* [Install from repository](#install-from-repository)
|
|
308
|
+
* [Execute a single test](#execute-a-single-test)
|
|
309
|
+
* [Execute a test suite by ID](#execute-a-test-suite-by-id)
|
|
310
|
+
* [Execute by name with JSON output (perfect for CI/CD)](#execute-by-name-with-json-output-perfect-for-cicd)
|
|
311
|
+
* [Configure browser and performance settings](#configure-browser-and-performance-settings)
|
|
312
|
+
* [Install applications from batch definition](#install-applications-from-batch-definition)
|
|
313
|
+
* [Uninstall an application](#uninstall-an-application)
|
|
314
|
+
* [List repository applications (what's available to install)](#list-repository-applications-whats-available-to-install)
|
|
315
|
+
* [Install from company repository](#install-from-company-repository)
|
|
316
|
+
* [List installed repository apps](#list-installed-repository-apps)
|
|
317
|
+
* [Script with placeholders: {username}, {table}](#script-with-placeholders-username-table)
|
|
318
|
+
* [See what's available](#see-whats-available)
|
|
319
|
+
* [Filter for installable apps](#filter-for-installable-apps)
|
|
320
|
+
* [Install by scope (automatic lookup)](#install-by-scope-automatic-lookup)
|
|
321
|
+
* [Install specific version](#install-specific-version)
|
|
322
|
+
* [Background installation](#background-installation)
|
|
22
323
|
* [Usage](#usage)
|
|
23
324
|
* [Commands](#commands)
|
|
325
|
+
* [Global scope](#global-scope)
|
|
326
|
+
* [Custom application scope](#custom-application-scope)
|
|
327
|
+
* [Development](#development)
|
|
328
|
+
* [Production](#production)
|
|
329
|
+
* [GitHub Actions](#github-actions)
|
|
330
|
+
* [1. Enable autocomplete](#1-enable-autocomplete)
|
|
331
|
+
* [2. Follow shell-specific instructions (bash/zsh/fish)](#2-follow-shell-specific-instructions-bashzshfish)
|
|
332
|
+
* [3. Reload shell](#3-reload-shell)
|
|
333
|
+
* [4. Start using it!](#4-start-using-it)
|
|
334
|
+
* [Autocomplete queries ServiceNow and shows:](#autocomplete-queries-servicenow-and-shows)
|
|
335
|
+
* [Ready to execute!](#ready-to-execute)
|
|
336
|
+
* [Add credentials interactively (will prompt for username/password)](#add-credentials-interactively-will-prompt-for-usernamepassword)
|
|
337
|
+
* [For OAuth authentication](#for-oauth-authentication)
|
|
338
|
+
* [List all configured authentication profiles](#list-all-configured-authentication-profiles)
|
|
339
|
+
* [Set default authentication profile (optional)](#set-default-authentication-profile-optional)
|
|
340
|
+
* [Delete an authentication profile](#delete-an-authentication-profile)
|
|
341
|
+
* [Use specific authentication profile via --auth flag](#use-specific-authentication-profile-via---auth-flag)
|
|
342
|
+
* [Use default profile (if set with --use)](#use-default-profile-if-set-with---use)
|
|
343
|
+
* [All commands support the --auth flag](#all-commands-support-the---auth-flag)
|
|
344
|
+
* [Set credentials in environment](#set-credentials-in-environment)
|
|
345
|
+
* [Add authentication profile (will use environment variables)](#add-authentication-profile-will-use-environment-variables)
|
|
346
|
+
* [1. List available repository apps](#1-list-available-repository-apps)
|
|
347
|
+
* [2. Install application from repository](#2-install-application-from-repository)
|
|
348
|
+
* [3. Configure using REPL](#3-configure-using-repl)
|
|
349
|
+
* [4. Run tests](#4-run-tests)
|
|
350
|
+
* [5. Deploy to production with parameterized script](#5-deploy-to-production-with-parameterized-script)
|
|
351
|
+
* [6. Verify deployment](#6-verify-deployment)
|
|
352
|
+
* [Execute a single test](#execute-a-single-test)
|
|
353
|
+
* [Execute a test suite and wait for results](#execute-a-test-suite-and-wait-for-results)
|
|
354
|
+
* [Execute by name (no need to look up sys_id)](#execute-by-name-no-need-to-look-up-sys_id)
|
|
355
|
+
* [Performance test with specific browser](#performance-test-with-specific-browser)
|
|
356
|
+
* [CI/CD integration with JSON output](#cicd-integration-with-json-output)
|
|
357
|
+
* [Custom polling for long tests](#custom-polling-for-long-tests)
|
|
358
|
+
* [Browse company repository](#browse-company-repository)
|
|
359
|
+
* [Install from repository](#install-from-repository)
|
|
360
|
+
* [Batch install multiple apps](#batch-install-multiple-apps)
|
|
361
|
+
* [Uninstall application](#uninstall-application)
|
|
362
|
+
* [Execute script file](#execute-script-file)
|
|
363
|
+
* [Execute in custom scope](#execute-in-custom-scope)
|
|
364
|
+
* [Pipe output](#pipe-output)
|
|
365
|
+
* [Start REPL](#start-repl)
|
|
366
|
+
* [Execute multi-line scripts interactively](#execute-multi-line-scripts-interactively)
|
|
367
|
+
* [Single parameter](#single-parameter)
|
|
368
|
+
* [Multiple parameters](#multiple-parameters)
|
|
369
|
+
* [From environment variables](#from-environment-variables)
|
|
370
|
+
* [daily-tests.sh](#daily-testssh)
|
|
371
|
+
* [setup-environment.sh](#setup-environmentsh)
|
|
372
|
+
* [Install required apps from repository](#install-required-apps-from-repository)
|
|
373
|
+
* [Configure via parameterized script](#configure-via-parameterized-script)
|
|
374
|
+
* [Validate with ATF](#validate-with-atf)
|
|
375
|
+
* [migrate-data.sh](#migrate-datash)
|
|
376
|
+
* [Export from source](#export-from-source)
|
|
377
|
+
* [Transform data](#transform-data)
|
|
378
|
+
* [Import to target with parameters](#import-to-target-with-parameters)
|
|
379
|
+
* [Validate](#validate)
|
|
380
|
+
* [List all configured authentication profiles](#list-all-configured-authentication-profiles)
|
|
381
|
+
* [Delete and re-add credentials if needed](#delete-and-re-add-credentials-if-needed)
|
|
382
|
+
* [Set as default](#set-as-default)
|
|
383
|
+
* [Verify installation](#verify-installation)
|
|
384
|
+
* [Reinstall if needed](#reinstall-if-needed)
|
|
385
|
+
* [Check PATH includes npm global binaries](#check-path-includes-npm-global-binaries)
|
|
386
|
+
* [Increase poll interval](#increase-poll-interval)
|
|
387
|
+
* [Check instance performance](#check-instance-performance)
|
|
388
|
+
* [Check test suite complexity](#check-test-suite-complexity)
|
|
389
|
+
* [Review ServiceNow logs](#review-servicenow-logs)
|
|
390
|
+
* [Verify user has required roles:](#verify-user-has-required-roles)
|
|
391
|
+
* [- atf_test_runner for ATF operations](#--atf_test_runner-for-atf-operations)
|
|
392
|
+
* [- admin for app management](#--admin-for-app-management)
|
|
393
|
+
* [- appropriate scope access for scripts](#--appropriate-scope-access-for-scripts)
|
|
394
|
+
* [General help](#general-help)
|
|
395
|
+
* [Command-specific help](#command-specific-help)
|
|
396
|
+
* [Command-specific help](#command-specific-help)
|
|
397
|
+
* [Enable autocomplete](#enable-autocomplete)
|
|
398
|
+
* [Clone the repository](#clone-the-repository)
|
|
399
|
+
* [Install dependencies](#install-dependencies)
|
|
400
|
+
* [Build](#build)
|
|
401
|
+
* [Run tests (48 unit tests)](#run-tests-48-unit-tests)
|
|
402
|
+
* [Run linter](#run-linter)
|
|
403
|
+
* [Test locally](#test-locally)
|
|
404
|
+
* [All tests](#all-tests)
|
|
405
|
+
* [Specific test file](#specific-test-file)
|
|
406
|
+
* [With coverage](#with-coverage)
|
|
24
407
|
<!-- tocstop -->
|
|
408
|
+
|
|
25
409
|
# Usage
|
|
26
410
|
<!-- usage -->
|
|
27
411
|
```sh-session
|
|
@@ -29,19 +413,26 @@ $ npm install -g @sonisoft/now-sdk-ext-cli
|
|
|
29
413
|
$ nex COMMAND
|
|
30
414
|
running command...
|
|
31
415
|
$ nex (--version)
|
|
32
|
-
@sonisoft/now-sdk-ext-cli/
|
|
416
|
+
@sonisoft/now-sdk-ext-cli/2.0.0-alpha.0 darwin-arm64 node-v22.6.0
|
|
33
417
|
$ nex --help [COMMAND]
|
|
34
418
|
USAGE
|
|
35
419
|
$ nex COMMAND
|
|
36
420
|
...
|
|
37
421
|
```
|
|
38
422
|
<!-- usagestop -->
|
|
423
|
+
|
|
39
424
|
# Commands
|
|
40
425
|
<!-- commands -->
|
|
41
426
|
* [`nex app`](#nex-app)
|
|
42
427
|
* [`nex app install`](#nex-app-install)
|
|
43
|
-
* [`nex
|
|
428
|
+
* [`nex app repo-install`](#nex-app-repo-install)
|
|
429
|
+
* [`nex app repo-list`](#nex-app-repo-list)
|
|
430
|
+
* [`nex app uninstall`](#nex-app-uninstall)
|
|
431
|
+
* [`nex atf`](#nex-atf)
|
|
432
|
+
* [`nex autocomplete [SHELL]`](#nex-autocomplete-shell)
|
|
433
|
+
* [`nex exec SCOPE [FILE]`](#nex-exec-scope-file)
|
|
44
434
|
* [`nex help [COMMAND]`](#nex-help-command)
|
|
435
|
+
* [`nex log`](#nex-log)
|
|
45
436
|
* [`nex plugins`](#nex-plugins)
|
|
46
437
|
* [`nex plugins add PLUGIN`](#nex-plugins-add-plugin)
|
|
47
438
|
* [`nex plugins:inspect PLUGIN...`](#nex-pluginsinspect-plugin)
|
|
@@ -55,6 +446,8 @@ USAGE
|
|
|
55
446
|
|
|
56
447
|
## `nex app`
|
|
57
448
|
|
|
449
|
+
Manage ServiceNow applications: uninstall applications from your instance.
|
|
450
|
+
|
|
58
451
|
```
|
|
59
452
|
USAGE
|
|
60
453
|
$ nex app [--json] [-a <value>] [--log-level debug|warn|error|info|trace] [-u] [-i <value>] [-s <value>]
|
|
@@ -70,14 +463,40 @@ GLOBAL FLAGS
|
|
|
70
463
|
--log-level=<option> [default: info] Specify level for logging.
|
|
71
464
|
<options: debug|warn|error|info|trace>
|
|
72
465
|
|
|
466
|
+
DESCRIPTION
|
|
467
|
+
Manage ServiceNow applications: uninstall applications from your instance.
|
|
468
|
+
|
|
469
|
+
This command provides programmatic control over ServiceNow applications, allowing you to uninstall applications
|
|
470
|
+
remotely. This is useful for automated environment cleanup, testing workflows, and application lifecycle management.
|
|
471
|
+
|
|
472
|
+
Features:
|
|
473
|
+
โข Uninstall applications by sys_id and scope
|
|
474
|
+
โข Automated application removal in CI/CD pipelines
|
|
475
|
+
โข Proper cleanup and rollback handling
|
|
476
|
+
โข Detailed logging and error reporting
|
|
477
|
+
|
|
478
|
+
Requirements:
|
|
479
|
+
โข User must have admin role
|
|
480
|
+
โข Application must be in a removable state
|
|
481
|
+
โข Both application sys_id and scope are required
|
|
482
|
+
|
|
73
483
|
EXAMPLES
|
|
74
|
-
|
|
75
|
-
|
|
484
|
+
Uninstall an application by sys_id and scope
|
|
485
|
+
|
|
486
|
+
$ nex app --uninstall --applicationId a1b2c3d4e5f6 --scope x_my_custom_app --auth dev-instance
|
|
487
|
+
|
|
488
|
+
Uninstall with enhanced debug logging
|
|
489
|
+
|
|
490
|
+
$ nex app -u -i a1b2c3d4e5f6 -s x_my_custom_app --auth dev-instance --log-level debug
|
|
491
|
+
|
|
492
|
+
Uninstall using short flags
|
|
493
|
+
|
|
494
|
+
$ nex app -u -i a1b2c3d4e5f6 -s x_my_custom_app -a dev-instance
|
|
76
495
|
```
|
|
77
496
|
|
|
78
497
|
## `nex app install`
|
|
79
498
|
|
|
80
|
-
Install or
|
|
499
|
+
Install or upgrade multiple ServiceNow applications from a batch definition file.
|
|
81
500
|
|
|
82
501
|
```
|
|
83
502
|
USAGE
|
|
@@ -85,8 +504,8 @@ USAGE
|
|
|
85
504
|
|
|
86
505
|
FLAGS
|
|
87
506
|
-a, --auth=<value> Auth alias to use.
|
|
88
|
-
-b, --batch
|
|
89
|
-
-d, --definitionPath=<value>
|
|
507
|
+
-b, --batch Enable batch installation mode from definition file
|
|
508
|
+
-d, --definitionPath=<value> Path to JSON batch definition file containing applications to install
|
|
90
509
|
|
|
91
510
|
GLOBAL FLAGS
|
|
92
511
|
--json Format output as json.
|
|
@@ -94,27 +513,341 @@ GLOBAL FLAGS
|
|
|
94
513
|
<options: debug|warn|error|info|trace>
|
|
95
514
|
|
|
96
515
|
DESCRIPTION
|
|
97
|
-
Install or
|
|
516
|
+
Install or upgrade multiple ServiceNow applications from a batch definition file.
|
|
517
|
+
|
|
518
|
+
This command enables automated installation and upgrade of multiple applications using a JSON definition file. Perfect
|
|
519
|
+
for setting up new environments, deploying application bundles, or managing application dependencies. The batch file
|
|
520
|
+
can specify multiple applications with their versions, scopes, and installation options.
|
|
521
|
+
|
|
522
|
+
Features:
|
|
523
|
+
โข Install multiple applications in a single operation
|
|
524
|
+
โข Upgrade existing applications to new versions
|
|
525
|
+
โข Control demo data loading per application
|
|
526
|
+
โข Detailed installation progress and results
|
|
527
|
+
โข Automatic dependency resolution
|
|
528
|
+
โข Rollback support on failures
|
|
529
|
+
|
|
530
|
+
Batch Definition Format:
|
|
531
|
+
The JSON file should contain an "applications" array with objects defining:
|
|
532
|
+
โข name: Application name
|
|
533
|
+
โข scope: Application scope (e.g., x_my_app)
|
|
534
|
+
โข version: Target version number
|
|
535
|
+
โข load_demo_data: Whether to load demo data (optional)
|
|
536
|
+
โข notes: Installation notes (optional)
|
|
98
537
|
|
|
99
538
|
EXAMPLES
|
|
100
|
-
|
|
101
|
-
|
|
539
|
+
Install applications from a batch definition file
|
|
540
|
+
|
|
541
|
+
$ nex app install --batch --definitionPath ./apps-to-install.json --auth dev-instance
|
|
542
|
+
|
|
543
|
+
Install with short flags
|
|
544
|
+
|
|
545
|
+
$ nex app install -b -d ./batch-apps.json -a dev-instance
|
|
546
|
+
|
|
547
|
+
Install with debug logging to troubleshoot issues
|
|
548
|
+
|
|
549
|
+
$ nex app install -b -d ./apps.json -a dev-instance --log-level debug
|
|
102
550
|
```
|
|
103
551
|
|
|
104
|
-
## `nex
|
|
552
|
+
## `nex app repo-install`
|
|
105
553
|
|
|
106
|
-
|
|
554
|
+
Install an application from your ServiceNow company repository.
|
|
107
555
|
|
|
108
556
|
```
|
|
109
557
|
USAGE
|
|
110
|
-
$ nex
|
|
558
|
+
$ nex app repo-install -s <value> [--json] [-a <value>] [--log-level debug|warn|error|info|trace] [-w]
|
|
559
|
+
[--poll-interval <value>] [-t <value>] [-v <value>]
|
|
111
560
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
561
|
+
FLAGS
|
|
562
|
+
-a, --auth=<value> Auth alias to use.
|
|
563
|
+
-s, --scope=<value> (required) Application scope (e.g., x_my_custom_app)
|
|
564
|
+
-t, --timeout=<value> [default: 1800000] Installation timeout in milliseconds (default: 1800000 = 30 min)
|
|
565
|
+
-v, --version=<value> Specific version to install (defaults to latest)
|
|
566
|
+
-w, --no-wait Do not wait for installation to complete
|
|
567
|
+
--poll-interval=<value> [default: 5000] Polling interval in milliseconds (default: 5000)
|
|
568
|
+
|
|
569
|
+
GLOBAL FLAGS
|
|
570
|
+
--json Format output as json.
|
|
571
|
+
--log-level=<option> [default: info] Specify level for logging.
|
|
572
|
+
<options: debug|warn|error|info|trace>
|
|
573
|
+
|
|
574
|
+
DESCRIPTION
|
|
575
|
+
Install an application from your ServiceNow company repository.
|
|
576
|
+
|
|
577
|
+
This command installs an application from your company's internal application repository. You can specify the
|
|
578
|
+
application by its scope name, and optionally specify a particular version. The command will automatically look up the
|
|
579
|
+
application details and initiate the installation.
|
|
580
|
+
|
|
581
|
+
Features:
|
|
582
|
+
โข Install applications by scope name
|
|
583
|
+
โข Automatic lookup of application sys_id
|
|
584
|
+
โข Optional version specification (defaults to latest)
|
|
585
|
+
โข Wait for installation completion with progress monitoring
|
|
586
|
+
โข No-wait mode for background installations
|
|
587
|
+
โข Configurable polling intervals and timeouts
|
|
588
|
+
โข Detailed installation status and error reporting
|
|
589
|
+
|
|
590
|
+
Installation Process:
|
|
591
|
+
1. Looks up the application in the company repository by scope
|
|
592
|
+
2. Verifies the application is available and installable
|
|
593
|
+
3. Initiates the installation via CI/CD API
|
|
594
|
+
4. Monitors progress until completion (unless --no-wait specified)
|
|
595
|
+
5. Reports final status and any errors
|
|
596
|
+
|
|
597
|
+
Requirements:
|
|
598
|
+
โข User must have sn_cicd.sys_ci_automation role
|
|
599
|
+
โข Application must exist in company repository
|
|
600
|
+
โข Application must not be already installed (or use upgrade)
|
|
601
|
+
|
|
602
|
+
EXAMPLES
|
|
603
|
+
Install application by scope (latest version)
|
|
604
|
+
|
|
605
|
+
$ nex app repo-install --scope x_my_custom_app --auth dev-instance
|
|
606
|
+
|
|
607
|
+
Install specific version of an application
|
|
608
|
+
|
|
609
|
+
$ nex app repo-install --scope x_my_app --version 2.1.0 --auth dev-instance
|
|
610
|
+
|
|
611
|
+
Install without waiting for completion
|
|
612
|
+
|
|
613
|
+
$ nex app repo-install --scope x_my_app --no-wait --auth dev-instance
|
|
614
|
+
|
|
615
|
+
Install with custom timeout (1 hour)
|
|
616
|
+
|
|
617
|
+
$ nex app repo-install -s x_my_app -a dev-instance --timeout 3600000
|
|
618
|
+
|
|
619
|
+
Install with debug logging
|
|
620
|
+
|
|
621
|
+
$ nex app repo-install -s x_my_app -a dev-instance --log-level debug
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
## `nex app repo-list`
|
|
625
|
+
|
|
626
|
+
List applications available in your ServiceNow company repository.
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
USAGE
|
|
630
|
+
$ nex app repo-list [-j] [-a <value>] [--log-level debug|warn|error|info|trace] [-n] [-i]
|
|
115
631
|
|
|
116
632
|
FLAGS
|
|
117
633
|
-a, --auth=<value> Auth alias to use.
|
|
634
|
+
-i, --installed Show only installed applications
|
|
635
|
+
-j, --json Output results as JSON
|
|
636
|
+
-n, --installable Show only applications that can be installed (not yet installed)
|
|
637
|
+
|
|
638
|
+
GLOBAL FLAGS
|
|
639
|
+
--log-level=<option> [default: info] Specify level for logging.
|
|
640
|
+
<options: debug|warn|error|info|trace>
|
|
641
|
+
|
|
642
|
+
DESCRIPTION
|
|
643
|
+
List applications available in your ServiceNow company repository.
|
|
644
|
+
|
|
645
|
+
This command retrieves and displays all applications that are available in your company's internal application
|
|
646
|
+
repository. These are applications that have been published internally and are available for installation across your
|
|
647
|
+
ServiceNow instances.
|
|
648
|
+
|
|
649
|
+
Features:
|
|
650
|
+
โข List all available company repository applications
|
|
651
|
+
โข Filter to show only installed applications
|
|
652
|
+
โข Filter to show only installable (not yet installed) applications
|
|
653
|
+
โข View application details including versions and dependencies
|
|
654
|
+
โข JSON output support for automation and scripting
|
|
655
|
+
โข Vendor-based filtering
|
|
656
|
+
|
|
657
|
+
Use Cases:
|
|
658
|
+
โข Discover available applications for installation
|
|
659
|
+
โข Audit installed company applications
|
|
660
|
+
โข Find applications that can be upgraded
|
|
661
|
+
โข Integration with CI/CD pipelines
|
|
662
|
+
โข Automated environment setup and configuration
|
|
663
|
+
|
|
664
|
+
EXAMPLES
|
|
665
|
+
List all company repository applications
|
|
666
|
+
|
|
667
|
+
$ nex app repo-list --auth dev-instance
|
|
668
|
+
|
|
669
|
+
List only installed applications
|
|
670
|
+
|
|
671
|
+
$ nex app repo-list --installed --auth dev-instance
|
|
672
|
+
|
|
673
|
+
List only installable (not installed) applications
|
|
674
|
+
|
|
675
|
+
$ nex app repo-list --installable --auth dev-instance
|
|
676
|
+
|
|
677
|
+
Get JSON output for scripting
|
|
678
|
+
|
|
679
|
+
$ nex app repo-list --json --auth dev-instance
|
|
680
|
+
|
|
681
|
+
List with short flags
|
|
682
|
+
|
|
683
|
+
$ nex app repo-list -a dev-instance
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
## `nex app uninstall`
|
|
687
|
+
|
|
688
|
+
Uninstall a ServiceNow application from your instance.
|
|
689
|
+
|
|
690
|
+
```
|
|
691
|
+
USAGE
|
|
692
|
+
$ nex app uninstall -i <value> -s <value> [--json] [-a <value>] [--log-level debug|warn|error|info|trace]
|
|
693
|
+
|
|
694
|
+
FLAGS
|
|
695
|
+
-a, --auth=<value> Auth alias to use.
|
|
696
|
+
-i, --applicationId=<value> (required) Application sys_id
|
|
697
|
+
-s, --scope=<value> (required) Scope of application
|
|
698
|
+
|
|
699
|
+
GLOBAL FLAGS
|
|
700
|
+
--json Format output as json.
|
|
701
|
+
--log-level=<option> [default: info] Specify level for logging.
|
|
702
|
+
<options: debug|warn|error|info|trace>
|
|
703
|
+
|
|
704
|
+
DESCRIPTION
|
|
705
|
+
Uninstall a ServiceNow application from your instance.
|
|
706
|
+
|
|
707
|
+
This command provides programmatic control over ServiceNow application removal, allowing you to uninstall applications
|
|
708
|
+
remotely. This is useful for automated environment cleanup, testing workflows, and application lifecycle management.
|
|
709
|
+
|
|
710
|
+
Features:
|
|
711
|
+
โข Uninstall applications by sys_id and scope
|
|
712
|
+
โข Automated application removal in CI/CD pipelines
|
|
713
|
+
โข Proper cleanup and rollback handling
|
|
714
|
+
โข Detailed logging and error reporting
|
|
715
|
+
|
|
716
|
+
Requirements:
|
|
717
|
+
โข User must have admin role
|
|
718
|
+
โข Application must be in a removable state
|
|
719
|
+
โข Both application sys_id and scope are required
|
|
720
|
+
|
|
721
|
+
EXAMPLES
|
|
722
|
+
Uninstall an application by sys_id and scope
|
|
723
|
+
|
|
724
|
+
$ nex app uninstall --applicationId a1b2c3d4e5f6 --scope x_my_custom_app --auth dev-instance
|
|
725
|
+
|
|
726
|
+
Uninstall with enhanced debug logging
|
|
727
|
+
|
|
728
|
+
$ nex app uninstall -i a1b2c3d4e5f6 -s x_my_custom_app --auth dev-instance --log-level debug
|
|
729
|
+
|
|
730
|
+
Uninstall using short flags
|
|
731
|
+
|
|
732
|
+
$ nex app uninstall -i a1b2c3d4e5f6 -s x_my_custom_app -a dev-instance
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
## `nex atf`
|
|
736
|
+
|
|
737
|
+
Execute ATF (Automated Test Framework) tests or test suites on a ServiceNow instance.
|
|
738
|
+
|
|
739
|
+
```
|
|
740
|
+
USAGE
|
|
741
|
+
$ nex atf [-j] [-a <value>] [--log-level debug|warn|error|info|trace] [-t <value> | -s <value> | -n
|
|
742
|
+
<value>] [-w] [-p <value>] [-b <value>] [--browser-version <value>] [--os-name <value>] [--os-version <value>]
|
|
743
|
+
[--performance] [--cloud]
|
|
744
|
+
|
|
745
|
+
FLAGS
|
|
746
|
+
-a, --auth=<value> Auth alias to use.
|
|
747
|
+
-b, --browser=<value> Browser name for test execution (e.g., chrome, firefox)
|
|
748
|
+
-j, --json Output results as JSON
|
|
749
|
+
-n, --suite-name=<value> Test Suite name to execute
|
|
750
|
+
-p, --poll-interval=<value> [default: 5000] Polling interval in milliseconds when waiting for completion
|
|
751
|
+
-s, --suite-id=<value> Test Suite sys_id to execute
|
|
752
|
+
-t, --test-id=<value> Test sys_id to execute
|
|
753
|
+
-w, --wait Wait for test suite execution to complete and return results
|
|
754
|
+
--browser-version=<value> Browser version for test execution
|
|
755
|
+
--cloud Run in cloud
|
|
756
|
+
--os-name=<value> Operating system name for test execution
|
|
757
|
+
--os-version=<value> Operating system version for test execution
|
|
758
|
+
--performance Run as performance test
|
|
759
|
+
|
|
760
|
+
GLOBAL FLAGS
|
|
761
|
+
--log-level=<option> [default: info] Specify level for logging.
|
|
762
|
+
<options: debug|warn|error|info|trace>
|
|
763
|
+
|
|
764
|
+
DESCRIPTION
|
|
765
|
+
Execute ATF (Automated Test Framework) tests or test suites on a ServiceNow instance.
|
|
766
|
+
|
|
767
|
+
This command allows you to run automated tests and test suites remotely, making it perfect for CI/CD pipelines and
|
|
768
|
+
automated testing workflows. You can execute individual tests, entire test suites, and configure execution parameters
|
|
769
|
+
such as browser type, OS, and performance mode.
|
|
770
|
+
|
|
771
|
+
Features:
|
|
772
|
+
โข Execute individual tests or complete test suites
|
|
773
|
+
โข Real-time progress monitoring
|
|
774
|
+
โข JSON output for CI/CD integration
|
|
775
|
+
โข Detailed test results and summaries
|
|
776
|
+
โข Browser and environment configuration
|
|
777
|
+
โข Performance testing mode support
|
|
778
|
+
|
|
779
|
+
EXAMPLES
|
|
780
|
+
Execute a single ATF test by sys_id
|
|
781
|
+
|
|
782
|
+
$ nex atf --test-id f717a8c783103210621e78c6feaad396 --auth dev-instance
|
|
783
|
+
|
|
784
|
+
Execute a test suite by sys_id and wait for completion
|
|
785
|
+
|
|
786
|
+
$ nex atf --suite-id e077e00b83103210621e78c6feaad383 --auth dev-instance --wait
|
|
787
|
+
|
|
788
|
+
Execute a test suite by name
|
|
789
|
+
|
|
790
|
+
$ nex atf --suite-name "Smoke Tests" --auth dev-instance
|
|
791
|
+
|
|
792
|
+
Execute with specific browser configuration
|
|
793
|
+
|
|
794
|
+
$ nex atf --suite-id e077e00b83103210621e78c6feaad383 --browser chrome --auth dev-instance
|
|
795
|
+
|
|
796
|
+
Execute as performance test with JSON output for CI/CD
|
|
797
|
+
|
|
798
|
+
$ nex atf --suite-id e077e00b83103210621e78c6feaad383 --performance --json --auth dev-instance
|
|
799
|
+
|
|
800
|
+
Execute with custom poll interval (10 seconds)
|
|
801
|
+
|
|
802
|
+
$ nex atf --suite-id e077e00b83103210621e78c6feaad383 --poll-interval 10000 --auth dev-instance
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
## `nex autocomplete [SHELL]`
|
|
806
|
+
|
|
807
|
+
Display autocomplete installation instructions.
|
|
808
|
+
|
|
809
|
+
```
|
|
810
|
+
USAGE
|
|
811
|
+
$ nex autocomplete [SHELL] [-r]
|
|
812
|
+
|
|
813
|
+
ARGUMENTS
|
|
814
|
+
SHELL (zsh|bash|powershell) Shell type
|
|
815
|
+
|
|
816
|
+
FLAGS
|
|
817
|
+
-r, --refresh-cache Refresh cache (ignores displaying instructions)
|
|
818
|
+
|
|
819
|
+
DESCRIPTION
|
|
820
|
+
Display autocomplete installation instructions.
|
|
821
|
+
|
|
822
|
+
EXAMPLES
|
|
823
|
+
$ nex autocomplete
|
|
824
|
+
|
|
825
|
+
$ nex autocomplete bash
|
|
826
|
+
|
|
827
|
+
$ nex autocomplete zsh
|
|
828
|
+
|
|
829
|
+
$ nex autocomplete powershell
|
|
830
|
+
|
|
831
|
+
$ nex autocomplete --refresh-cache
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.35/src/commands/autocomplete/index.ts)_
|
|
835
|
+
|
|
836
|
+
## `nex exec SCOPE [FILE]`
|
|
837
|
+
|
|
838
|
+
Execute JavaScript on a ServiceNow instance remotely using Scripts - Background.
|
|
839
|
+
|
|
840
|
+
```
|
|
841
|
+
USAGE
|
|
842
|
+
$ nex exec SCOPE [FILE] [--json] [-a <value>] [--log-level debug|warn|error|info|trace] [-p <value>]
|
|
843
|
+
|
|
844
|
+
ARGUMENTS
|
|
845
|
+
SCOPE Scope to execute script in. Use "global" for global scope.
|
|
846
|
+
FILE File to execute in scripts background. If omitted, starts REPL mode.
|
|
847
|
+
|
|
848
|
+
FLAGS
|
|
849
|
+
-a, --auth=<value> Auth alias to use.
|
|
850
|
+
-p, --params=<value> JSON object of parameters to replace in script file. Use {paramName} syntax in your script.
|
|
118
851
|
|
|
119
852
|
GLOBAL FLAGS
|
|
120
853
|
--json Format output as json.
|
|
@@ -122,13 +855,99 @@ GLOBAL FLAGS
|
|
|
122
855
|
<options: debug|warn|error|info|trace>
|
|
123
856
|
|
|
124
857
|
DESCRIPTION
|
|
125
|
-
Execute
|
|
126
|
-
|
|
127
|
-
|
|
858
|
+
Execute JavaScript on a ServiceNow instance remotely using Scripts - Background.
|
|
859
|
+
|
|
860
|
+
This command allows you to run JavaScript either from files or interactively via REPL mode. It mimics the
|
|
861
|
+
functionality of the Scripts - Background interface in ServiceNow, providing a way to execute scripts programmatically
|
|
862
|
+
without manual interaction. The output is returned in real-time and can be piped to other commands or saved to files.
|
|
863
|
+
|
|
864
|
+
Modes:
|
|
865
|
+
โข File Mode: Provide a file path to execute scripts from a file
|
|
866
|
+
โข REPL Mode: Omit the file path to start an interactive session
|
|
867
|
+
|
|
868
|
+
Features:
|
|
869
|
+
โข Execute local JavaScript files remotely
|
|
870
|
+
โข Interactive REPL for ad-hoc script execution
|
|
871
|
+
โข Script parameterization with {placeholder} replacement
|
|
872
|
+
โข Multi-line script support in REPL
|
|
873
|
+
โข Scope-aware execution (global or custom scope)
|
|
874
|
+
โข Real-time console output capture
|
|
875
|
+
โข Pipe-able output for command chaining
|
|
876
|
+
โข Debug logging support
|
|
877
|
+
โข Useful for data migration, testing, and administrative tasks
|
|
878
|
+
|
|
879
|
+
Script Parameterization:
|
|
880
|
+
Use {paramName} placeholders in your script files, then provide values via --params:
|
|
881
|
+
โข Supports any JSON-serializable values (strings, numbers, booleans)
|
|
882
|
+
โข Multiple parameters supported
|
|
883
|
+
โข All occurrences of each placeholder are replaced
|
|
884
|
+
โข Example: {token}, {username}, {environment}
|
|
885
|
+
|
|
886
|
+
REPL Controls:
|
|
887
|
+
โข Press Enter to add a new line
|
|
888
|
+
โข Type .exec or press Ctrl+D to execute the script
|
|
889
|
+
โข Type .clear to clear the current input
|
|
890
|
+
โข Type .exit or press Ctrl+C twice to exit REPL
|
|
891
|
+
|
|
892
|
+
โ ๏ธ IMPORTANT SECURITY WARNING:
|
|
893
|
+
This command executes scripts with the same permissions and risks as using Scripts - Background directly
|
|
894
|
+
in ServiceNow. Always:
|
|
895
|
+
โข Review scripts before execution
|
|
896
|
+
โข Test in non-production environments first
|
|
897
|
+
โข Use appropriate scoping to limit access
|
|
898
|
+
โข Be aware of data modification risks
|
|
899
|
+
โข Follow your organization's security policies
|
|
900
|
+
โข Never execute untrusted scripts
|
|
901
|
+
|
|
902
|
+
Script Capabilities:
|
|
903
|
+
Scripts run with full GlideSystem API access and can:
|
|
904
|
+
โข Query and modify database records
|
|
905
|
+
โข Create, update, and delete data
|
|
906
|
+
โข Execute business rules and workflows
|
|
907
|
+
โข Access all APIs available in Scripts - Background
|
|
908
|
+
โข Use gs, GlideRecord, GlideAggregate, and other server-side APIs
|
|
128
909
|
|
|
129
910
|
EXAMPLES
|
|
130
|
-
|
|
131
|
-
|
|
911
|
+
Start REPL in global scope
|
|
912
|
+
|
|
913
|
+
$ nex exec global --auth dev-instance
|
|
914
|
+
|
|
915
|
+
Start REPL in custom application scope
|
|
916
|
+
|
|
917
|
+
$ nex exec x_my_custom_app --auth dev-instance
|
|
918
|
+
|
|
919
|
+
Execute a script file in global scope
|
|
920
|
+
|
|
921
|
+
$ nex exec global ./scripts/cleanup.js --auth dev-instance
|
|
922
|
+
|
|
923
|
+
Execute a script file in a custom application scope
|
|
924
|
+
|
|
925
|
+
$ nex exec x_my_custom_app ./scripts/app-config.js --auth dev-instance
|
|
926
|
+
|
|
927
|
+
Execute a parameterized script with single parameter
|
|
928
|
+
|
|
929
|
+
$ nex exec global ./scripts/query-user.js --auth dev-instance --params '{"username":"admin"}'
|
|
930
|
+
|
|
931
|
+
Execute a parameterized script with multiple parameters
|
|
932
|
+
|
|
933
|
+
$ nex exec global ./scripts/update-record.js --auth dev-instance --params \
|
|
934
|
+
'{"table":"incident","field":"priority","value":"1"}'
|
|
935
|
+
|
|
936
|
+
Execute and save output to a file
|
|
937
|
+
|
|
938
|
+
$ nex exec global ./scripts/report.js --auth dev-instance > report.txt
|
|
939
|
+
|
|
940
|
+
Execute and pipe output to grep for filtering
|
|
941
|
+
|
|
942
|
+
$ nex exec global ./scripts/list-users.js --auth dev-instance | grep "admin"
|
|
943
|
+
|
|
944
|
+
Execute with debug logging to troubleshoot issues
|
|
945
|
+
|
|
946
|
+
$ nex exec global ./script.js --auth dev-instance --log-level debug
|
|
947
|
+
|
|
948
|
+
Execute with parameters for template replacement
|
|
949
|
+
|
|
950
|
+
$ nex exec global ./script.js --auth dev-instance --params '{"token":"abc123","env":"dev"}'
|
|
132
951
|
```
|
|
133
952
|
|
|
134
953
|
## `nex help [COMMAND]`
|
|
@@ -151,6 +970,109 @@ DESCRIPTION
|
|
|
151
970
|
|
|
152
971
|
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.32/src/commands/help.ts)_
|
|
153
972
|
|
|
973
|
+
## `nex log`
|
|
974
|
+
|
|
975
|
+
Tail and monitor ServiceNow system logs in real-time with beautiful formatting.
|
|
976
|
+
|
|
977
|
+
```
|
|
978
|
+
USAGE
|
|
979
|
+
$ nex log [--json] [-a <value>] [--log-level debug|warn|error|info|trace] [-o <value>] [-i <value>]
|
|
980
|
+
[--no-color] [-f <value>...]
|
|
981
|
+
|
|
982
|
+
FLAGS
|
|
983
|
+
-a, --auth=<value> Auth alias to use.
|
|
984
|
+
-f, --filter=<value>... Filter logs by field and value. Syntax: field OPERATOR value. Operators: CONTAINS,
|
|
985
|
+
CONTAINS_CI (case-insensitive), EQUALS, EQUALS_CI, STARTS_WITH, STARTS_WITH_CI, ENDS_WITH,
|
|
986
|
+
ENDS_WITH_CI, REGEX, NOT_CONTAINS, NOT_EQUALS. Field defaults to "message" if omitted.
|
|
987
|
+
Multiple filters are combined with AND logic.
|
|
988
|
+
-i, --interval=<value> [default: 1000] Polling interval in milliseconds
|
|
989
|
+
-o, --output=<value> Output file path to save logs. Creates parent directories if needed.
|
|
990
|
+
--no-color Disable colored output
|
|
991
|
+
|
|
992
|
+
GLOBAL FLAGS
|
|
993
|
+
--json Format output as json.
|
|
994
|
+
--log-level=<option> [default: info] Specify level for logging.
|
|
995
|
+
<options: debug|warn|error|info|trace>
|
|
996
|
+
|
|
997
|
+
DESCRIPTION
|
|
998
|
+
Tail and monitor ServiceNow system logs in real-time with beautiful formatting.
|
|
999
|
+
|
|
1000
|
+
This command provides real-time log monitoring with enhanced visual formatting using color-coded output that makes
|
|
1001
|
+
logs easy to scan and understand at a glance. Automatically highlights errors, warnings, success messages, and
|
|
1002
|
+
important keywords.
|
|
1003
|
+
|
|
1004
|
+
Key Features:
|
|
1005
|
+
โข Real-time log tailing (like Unix tail -f)
|
|
1006
|
+
โข Powerful filtering with multiple operators (CONTAINS, REGEX, EQUALS, etc.)
|
|
1007
|
+
โข Smart keyword highlighting (errors in red, warnings in yellow, etc.)
|
|
1008
|
+
โข Beautiful color-coded console output with chalk
|
|
1009
|
+
โข Export logs to file with automatic appending
|
|
1010
|
+
โข Fast 1-second default polling interval
|
|
1011
|
+
โข Timestamps and sequence numbers for each log
|
|
1012
|
+
โข Graceful shutdown with Ctrl+C
|
|
1013
|
+
โข Clean output without colors (--no-color flag)
|
|
1014
|
+
|
|
1015
|
+
Smart Highlighting:
|
|
1016
|
+
โข Error terms (error, exception, failed) - highlighted in RED
|
|
1017
|
+
โข Warning terms (warn, warning, deprecated) - highlighted in YELLOW
|
|
1018
|
+
โข Success terms (success, completed, done) - highlighted in GREEN
|
|
1019
|
+
โข System terms (system, user, transaction) - highlighted in BLUE
|
|
1020
|
+
|
|
1021
|
+
Filtering:
|
|
1022
|
+
โข Apply filters using --filter flag with syntax: "field OPERATOR value"
|
|
1023
|
+
โข Supports case-sensitive and case-insensitive operations
|
|
1024
|
+
โข Multiple filters are combined with AND logic
|
|
1025
|
+
โข Operators: CONTAINS, CONTAINS_CI, EQUALS, EQUALS_CI, STARTS_WITH, STARTS_WITH_CI,
|
|
1026
|
+
ENDS_WITH, ENDS_WITH_CI, REGEX, NOT_CONTAINS, NOT_CONTAINS_CI, NOT_EQUALS, NOT_EQUALS_CI
|
|
1027
|
+
|
|
1028
|
+
Use Cases:
|
|
1029
|
+
โข Monitor logs during application development
|
|
1030
|
+
โข Debug issues in real-time
|
|
1031
|
+
โข Track system events during deployments
|
|
1032
|
+
โข Filter logs for specific application or component
|
|
1033
|
+
โข Quickly spot errors and warnings
|
|
1034
|
+
โข Collect logs for analysis or audit trails
|
|
1035
|
+
|
|
1036
|
+
โ ๏ธ IMPORTANT NOTES:
|
|
1037
|
+
โข Press Ctrl+C to stop tailing and exit gracefully
|
|
1038
|
+
โข Log files are created/appended automatically
|
|
1039
|
+
โข Uses ChannelAjax when available for better performance
|
|
1040
|
+
โข Default poll interval is 1 second for real-time monitoring
|
|
1041
|
+
|
|
1042
|
+
EXAMPLES
|
|
1043
|
+
Tail all logs in real-time
|
|
1044
|
+
|
|
1045
|
+
$ nex log --auth dev-instance
|
|
1046
|
+
|
|
1047
|
+
Tail logs and save to a file
|
|
1048
|
+
|
|
1049
|
+
$ nex log --output ./logs/instance-logs.txt --auth dev-instance
|
|
1050
|
+
|
|
1051
|
+
Tail logs with custom polling interval (500ms for faster updates)
|
|
1052
|
+
|
|
1053
|
+
$ nex log --interval 500 --auth dev-instance
|
|
1054
|
+
|
|
1055
|
+
Filter logs containing specific text (case-insensitive)
|
|
1056
|
+
|
|
1057
|
+
$ nex log --filter "message CONTAINS_CI error" --auth dev-instance
|
|
1058
|
+
|
|
1059
|
+
Filter logs with multiple conditions (AND logic)
|
|
1060
|
+
|
|
1061
|
+
$ nex log --filter "message CONTAINS x_taniu_tan_core" --filter "message CONTAINS error" --auth dev-instance
|
|
1062
|
+
|
|
1063
|
+
Filter logs using regex pattern
|
|
1064
|
+
|
|
1065
|
+
$ nex log --filter "message REGEX .*exception.*" --auth dev-instance
|
|
1066
|
+
|
|
1067
|
+
Filter logs by message starting with a pattern
|
|
1068
|
+
|
|
1069
|
+
$ nex log --filter "message STARTS_WITH [ERROR]" --auth dev-instance
|
|
1070
|
+
|
|
1071
|
+
Tail logs without colored output
|
|
1072
|
+
|
|
1073
|
+
$ nex log --no-color --auth dev-instance
|
|
1074
|
+
```
|
|
1075
|
+
|
|
154
1076
|
## `nex plugins`
|
|
155
1077
|
|
|
156
1078
|
List installed plugins.
|
|
@@ -441,3 +1363,872 @@ DESCRIPTION
|
|
|
441
1363
|
|
|
442
1364
|
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.46/src/commands/plugins/update.ts)_
|
|
443
1365
|
<!-- commandsstop -->
|
|
1366
|
+
|
|
1367
|
+
---
|
|
1368
|
+
|
|
1369
|
+
## ๐ Advanced Features
|
|
1370
|
+
|
|
1371
|
+
### Interactive REPL Mode
|
|
1372
|
+
|
|
1373
|
+
The ServiceNow Script Executor REPL provides an interactive environment for executing scripts without creating files - perfect for quick queries, debugging, and exploration.
|
|
1374
|
+
|
|
1375
|
+
#### Starting the REPL
|
|
1376
|
+
|
|
1377
|
+
```bash
|
|
1378
|
+
# Global scope
|
|
1379
|
+
nex exec global --auth dev
|
|
1380
|
+
|
|
1381
|
+
# Custom application scope
|
|
1382
|
+
nex exec x_my_custom_app --auth dev
|
|
1383
|
+
```
|
|
1384
|
+
|
|
1385
|
+
#### REPL Interface
|
|
1386
|
+
|
|
1387
|
+
```
|
|
1388
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1389
|
+
โ ServiceNow Script Executor REPL โ
|
|
1390
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1391
|
+
Scope: global
|
|
1392
|
+
Instance: dev12345.service-now.com
|
|
1393
|
+
|
|
1394
|
+
Commands:
|
|
1395
|
+
.exec - Execute the current script
|
|
1396
|
+
.clear - Clear the current input
|
|
1397
|
+
.exit - Exit REPL
|
|
1398
|
+
Ctrl+D - Execute the current script
|
|
1399
|
+
Ctrl+C - Cancel current input or exit (press twice)
|
|
1400
|
+
|
|
1401
|
+
Type your script below (press Enter for new lines):
|
|
1402
|
+
|
|
1403
|
+
sn> var gr = new GlideRecord('incident');
|
|
1404
|
+
... gr.addQuery('priority', 1);
|
|
1405
|
+
... gr.setLimit(5);
|
|
1406
|
+
... gr.query();
|
|
1407
|
+
... while (gr.next()) {
|
|
1408
|
+
... gs.info(gr.number + ': ' + gr.short_description);
|
|
1409
|
+
... }
|
|
1410
|
+
... .exec
|
|
1411
|
+
|
|
1412
|
+
Executing script (7 lines)...
|
|
1413
|
+
|
|
1414
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1415
|
+
|
|
1416
|
+
*** Script: INC0001234: Server down
|
|
1417
|
+
*** Script: INC0001235: Network issue
|
|
1418
|
+
*** Script: INC0001236: Database error
|
|
1419
|
+
|
|
1420
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1421
|
+
โ Script executed successfully
|
|
1422
|
+
|
|
1423
|
+
sn>
|
|
1424
|
+
```
|
|
1425
|
+
|
|
1426
|
+
#### REPL Commands
|
|
1427
|
+
|
|
1428
|
+
| Command | Description |
|
|
1429
|
+
|---------|-------------|
|
|
1430
|
+
| `.exec` | Execute the current script buffer |
|
|
1431
|
+
| `.clear` | Clear the current input |
|
|
1432
|
+
| `.exit` | Exit REPL |
|
|
1433
|
+
| `Ctrl+D` | Execute and continue |
|
|
1434
|
+
| `Ctrl+C` (once) | Clear input |
|
|
1435
|
+
| `Ctrl+C` (twice) | Exit REPL |
|
|
1436
|
+
|
|
1437
|
+
#### Use Cases
|
|
1438
|
+
|
|
1439
|
+
- **Quick Queries**: Test GlideRecord queries without creating files
|
|
1440
|
+
- **Debugging**: Explore API behavior interactively
|
|
1441
|
+
- **Learning**: Learn ServiceNow APIs hands-on
|
|
1442
|
+
- **Prototyping**: Test logic before adding to applications
|
|
1443
|
+
- **Admin Tasks**: One-off administrative operations
|
|
1444
|
+
|
|
1445
|
+
๐ **Full Documentation**: [REPL Mode Guide](./docs/REPL_MODE.md)
|
|
1446
|
+
|
|
1447
|
+
---
|
|
1448
|
+
|
|
1449
|
+
### Script Parameterization
|
|
1450
|
+
|
|
1451
|
+
Create reusable script templates with runtime parameter replacement - perfect for multi-environment deployments and CI/CD.
|
|
1452
|
+
|
|
1453
|
+
#### Basic Usage
|
|
1454
|
+
|
|
1455
|
+
**1. Create a template script:**
|
|
1456
|
+
|
|
1457
|
+
**File: `deploy.js`**
|
|
1458
|
+
```javascript
|
|
1459
|
+
// Deploy to {environment}
|
|
1460
|
+
var config = {
|
|
1461
|
+
environment: '{environment}',
|
|
1462
|
+
apiEndpoint: '{api_endpoint}',
|
|
1463
|
+
debugMode: {debug_mode},
|
|
1464
|
+
timeout: {timeout}
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
gs.setProperty('app.config', JSON.stringify(config));
|
|
1468
|
+
gs.info('Deployed to: ' + config.environment);
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
**2. Execute with parameters:**
|
|
1472
|
+
|
|
1473
|
+
```bash
|
|
1474
|
+
# Development
|
|
1475
|
+
nex exec global ./deploy.js \
|
|
1476
|
+
--auth dev \
|
|
1477
|
+
--params '{"environment":"dev","api_endpoint":"https://dev-api.com","debug_mode":true,"timeout":60000}'
|
|
1478
|
+
|
|
1479
|
+
# Production
|
|
1480
|
+
nex exec global ./deploy.js \
|
|
1481
|
+
--auth prod \
|
|
1482
|
+
--params '{"environment":"prod","api_endpoint":"https://api.com","debug_mode":false,"timeout":30000}'
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
#### Parameter Syntax
|
|
1486
|
+
|
|
1487
|
+
Use `{paramName}` in your scripts:
|
|
1488
|
+
|
|
1489
|
+
```javascript
|
|
1490
|
+
var username = '{username}'; // String
|
|
1491
|
+
var retries = {max_retries}; // Number
|
|
1492
|
+
var enabled = {feature_enabled}; // Boolean
|
|
1493
|
+
var endpoint = '{api_endpoint}'; // URL
|
|
1494
|
+
```
|
|
1495
|
+
|
|
1496
|
+
Provide values via `--params` flag:
|
|
1497
|
+
|
|
1498
|
+
```bash
|
|
1499
|
+
--params '{"username":"admin","max_retries":3,"feature_enabled":true,"api_endpoint":"https://api.example.com"}'
|
|
1500
|
+
```
|
|
1501
|
+
|
|
1502
|
+
#### Advanced Examples
|
|
1503
|
+
|
|
1504
|
+
**API Integration:**
|
|
1505
|
+
```javascript
|
|
1506
|
+
var request = new sn_ws.RESTMessageV2();
|
|
1507
|
+
request.setEndpoint('{endpoint}');
|
|
1508
|
+
request.setRequestHeader('Authorization', 'Bearer {token}');
|
|
1509
|
+
var response = request.execute();
|
|
1510
|
+
```
|
|
1511
|
+
|
|
1512
|
+
**Bulk Operations:**
|
|
1513
|
+
```javascript
|
|
1514
|
+
var gr = new GlideRecord('{table}');
|
|
1515
|
+
gr.addQuery('{field}', '{value}');
|
|
1516
|
+
gr.query();
|
|
1517
|
+
while (gr.next()) {
|
|
1518
|
+
gr.setValue('{update_field}', '{update_value}');
|
|
1519
|
+
gr.update();
|
|
1520
|
+
}
|
|
1521
|
+
```
|
|
1522
|
+
|
|
1523
|
+
**CI/CD Integration:**
|
|
1524
|
+
```yaml
|
|
1525
|
+
# GitHub Actions
|
|
1526
|
+
- name: Deploy Script
|
|
1527
|
+
run: |
|
|
1528
|
+
nex exec global ./deploy.js \
|
|
1529
|
+
--auth ci \
|
|
1530
|
+
--params "{\"env\":\"${{ vars.ENVIRONMENT }}\",\"token\":\"${{ secrets.API_TOKEN }}\"}"
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
๐ **Full Documentation**: [Script Parameterization Guide](./docs/SCRIPT_PARAMETERIZATION.md)
|
|
1534
|
+
|
|
1535
|
+
---
|
|
1536
|
+
|
|
1537
|
+
### Shell Autocomplete
|
|
1538
|
+
|
|
1539
|
+
Intelligent tab completion that dynamically queries your ServiceNow instance for available scopes.
|
|
1540
|
+
|
|
1541
|
+
#### Setup (One-Time)
|
|
1542
|
+
|
|
1543
|
+
```bash
|
|
1544
|
+
# 1. Enable autocomplete
|
|
1545
|
+
nex autocomplete
|
|
1546
|
+
|
|
1547
|
+
# 2. Follow shell-specific instructions (bash/zsh/fish)
|
|
1548
|
+
|
|
1549
|
+
# 3. Reload shell
|
|
1550
|
+
source ~/.zshrc # or ~/.bashrc
|
|
1551
|
+
|
|
1552
|
+
# 4. Start using it!
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
#### Usage
|
|
1556
|
+
|
|
1557
|
+
```bash
|
|
1558
|
+
$ nex exec --auth dev x_tan[TAB]
|
|
1559
|
+
|
|
1560
|
+
# Autocomplete queries ServiceNow and shows:
|
|
1561
|
+
x_taniu_ai_itsm x_taniu_tan_core x_tanium_integration
|
|
1562
|
+
|
|
1563
|
+
$ nex exec --auth dev x_taniu_tan_core
|
|
1564
|
+
# Ready to execute!
|
|
1565
|
+
```
|
|
1566
|
+
|
|
1567
|
+
#### How It Works
|
|
1568
|
+
|
|
1569
|
+
1. **You type** and press Tab
|
|
1570
|
+
2. **CLI extracts** the `--auth` flag value
|
|
1571
|
+
3. **Queries ServiceNow** `sys_scope` table for matching scopes
|
|
1572
|
+
4. **Returns suggestions** from your actual instance
|
|
1573
|
+
5. **Caches results** for 5 minutes (fast subsequent lookups)
|
|
1574
|
+
|
|
1575
|
+
#### Features
|
|
1576
|
+
|
|
1577
|
+
- โ
Real-time querying of your ServiceNow instance
|
|
1578
|
+
- โ
Works with multiple instances (different cache per instance)
|
|
1579
|
+
- โ
Intelligent caching (5-minute TTL)
|
|
1580
|
+
- โ
Supports Basic Auth and OAuth
|
|
1581
|
+
- โ
Graceful fallback if query fails
|
|
1582
|
+
- โ
No configuration needed
|
|
1583
|
+
|
|
1584
|
+
๐ **Full Documentation**: [Autocomplete Guide](./docs/AUTOCOMPLETE.md) | [Quick Start](./docs/AUTOCOMPLETE_QUICKSTART.md)
|
|
1585
|
+
|
|
1586
|
+
---
|
|
1587
|
+
|
|
1588
|
+
## ๐ Authentication
|
|
1589
|
+
|
|
1590
|
+
### How Authentication Works
|
|
1591
|
+
|
|
1592
|
+
`now-sdk-ext-cli` uses the ServiceNow SDK's authentication system. You configure credentials once using the `now-sdk auth` command, and they're automatically available to all `nex` commands.
|
|
1593
|
+
|
|
1594
|
+
### Setting Up Authentication
|
|
1595
|
+
|
|
1596
|
+
```bash
|
|
1597
|
+
# Add credentials interactively (will prompt for username/password)
|
|
1598
|
+
now-sdk auth --add your-instance.service-now.com --type basic --alias prod
|
|
1599
|
+
|
|
1600
|
+
# For OAuth authentication
|
|
1601
|
+
now-sdk auth --add your-instance.service-now.com --type oauth --alias prod-oauth
|
|
1602
|
+
|
|
1603
|
+
# List all configured authentication profiles
|
|
1604
|
+
now-sdk auth --list
|
|
1605
|
+
|
|
1606
|
+
# Set default authentication profile (optional)
|
|
1607
|
+
now-sdk auth --use prod
|
|
1608
|
+
|
|
1609
|
+
# Delete an authentication profile
|
|
1610
|
+
now-sdk auth --delete old-instance
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
### Credential Storage
|
|
1614
|
+
|
|
1615
|
+
Credentials are securely stored in your operating system's keychain:
|
|
1616
|
+
- **macOS**: Keychain
|
|
1617
|
+
- **Linux**: Secret Service API (libsecret)
|
|
1618
|
+
- **Windows**: Credential Vault
|
|
1619
|
+
|
|
1620
|
+
Only authentication metadata (alias, instance URL, type) is stored in plain text configuration files.
|
|
1621
|
+
|
|
1622
|
+
### Using Authentication in Commands
|
|
1623
|
+
|
|
1624
|
+
```bash
|
|
1625
|
+
# Use specific authentication profile via --auth flag
|
|
1626
|
+
nex atf --test-id xyz123 --auth prod
|
|
1627
|
+
|
|
1628
|
+
# Use default profile (if set with --use)
|
|
1629
|
+
nex atf --test-id xyz123
|
|
1630
|
+
|
|
1631
|
+
# All commands support the --auth flag
|
|
1632
|
+
nex exec global ./script.js --auth prod
|
|
1633
|
+
nex app uninstall -i app-id -s x_scope --auth prod
|
|
1634
|
+
```
|
|
1635
|
+
|
|
1636
|
+
### Environment Variables for CI/CD
|
|
1637
|
+
|
|
1638
|
+
For automated environments, you can use environment variables:
|
|
1639
|
+
|
|
1640
|
+
```bash
|
|
1641
|
+
# Set credentials in environment
|
|
1642
|
+
export NOWSDK_INSTANCE=your-instance.service-now.com
|
|
1643
|
+
export NOWSDK_USER=admin
|
|
1644
|
+
export NOWSDK_PASSWORD=your-password
|
|
1645
|
+
|
|
1646
|
+
# Add authentication profile (will use environment variables)
|
|
1647
|
+
now-sdk auth --add $NOWSDK_INSTANCE --type basic --alias ci
|
|
1648
|
+
```
|
|
1649
|
+
|
|
1650
|
+
### For ServiceNow SDK Documentation
|
|
1651
|
+
|
|
1652
|
+
For complete authentication documentation, see:
|
|
1653
|
+
**ServiceNow SDK CLI Commands**: https://www.servicenow.com/docs/bundle/zurich-application-development/page/build/servicenow-sdk/reference/servicenow-sdk-cli-commands.html
|
|
1654
|
+
|
|
1655
|
+
## ๐ CI/CD Integration
|
|
1656
|
+
|
|
1657
|
+
### GitHub Actions Example
|
|
1658
|
+
|
|
1659
|
+
```yaml
|
|
1660
|
+
name: ServiceNow ATF Tests
|
|
1661
|
+
|
|
1662
|
+
on:
|
|
1663
|
+
push:
|
|
1664
|
+
branches: [ main, develop ]
|
|
1665
|
+
pull_request:
|
|
1666
|
+
branches: [ main ]
|
|
1667
|
+
|
|
1668
|
+
jobs:
|
|
1669
|
+
test:
|
|
1670
|
+
runs-on: ubuntu-latest
|
|
1671
|
+
|
|
1672
|
+
steps:
|
|
1673
|
+
- uses: actions/checkout@v3
|
|
1674
|
+
|
|
1675
|
+
- name: Setup Node.js
|
|
1676
|
+
uses: actions/setup-node@v3
|
|
1677
|
+
with:
|
|
1678
|
+
node-version: '20'
|
|
1679
|
+
|
|
1680
|
+
- name: Install Dependencies
|
|
1681
|
+
run: |
|
|
1682
|
+
npm install -g @servicenow/sdk
|
|
1683
|
+
npm install -g @sonisoft/now-sdk-ext-cli
|
|
1684
|
+
|
|
1685
|
+
- name: Configure ServiceNow Authentication
|
|
1686
|
+
env:
|
|
1687
|
+
NOWSDK_INSTANCE: ${{ secrets.SN_INSTANCE }}
|
|
1688
|
+
NOWSDK_USER: ${{ secrets.SN_USER }}
|
|
1689
|
+
NOWSDK_PASSWORD: ${{ secrets.SN_PASSWORD }}
|
|
1690
|
+
run: |
|
|
1691
|
+
now-sdk auth --add $NOWSDK_INSTANCE --type basic --alias ci-instance
|
|
1692
|
+
|
|
1693
|
+
- name: Run ATF Test Suite
|
|
1694
|
+
run: |
|
|
1695
|
+
nex atf \
|
|
1696
|
+
--suite-id ${{ vars.TEST_SUITE_ID }} \
|
|
1697
|
+
--auth ci-instance \
|
|
1698
|
+
--json > test-results.json
|
|
1699
|
+
|
|
1700
|
+
- name: Upload Test Results
|
|
1701
|
+
if: always()
|
|
1702
|
+
uses: actions/upload-artifact@v3
|
|
1703
|
+
with:
|
|
1704
|
+
name: test-results
|
|
1705
|
+
path: test-results.json
|
|
1706
|
+
```
|
|
1707
|
+
|
|
1708
|
+
### GitLab CI Example
|
|
1709
|
+
|
|
1710
|
+
```yaml
|
|
1711
|
+
servicenow-tests:
|
|
1712
|
+
image: node:20
|
|
1713
|
+
stage: test
|
|
1714
|
+
before_script:
|
|
1715
|
+
- npm install -g @servicenow/sdk
|
|
1716
|
+
- npm install -g @sonisoft/now-sdk-ext-cli
|
|
1717
|
+
- export NOWSDK_INSTANCE=$SN_INSTANCE NOWSDK_USER=$SN_USER NOWSDK_PASSWORD=$SN_PASSWORD
|
|
1718
|
+
- now-sdk auth --add $SN_INSTANCE --type basic --alias ci
|
|
1719
|
+
script:
|
|
1720
|
+
- nex atf --suite-id $TEST_SUITE_ID --auth ci --json > test-results.json
|
|
1721
|
+
artifacts:
|
|
1722
|
+
when: always
|
|
1723
|
+
reports:
|
|
1724
|
+
junit: test-results.json
|
|
1725
|
+
paths:
|
|
1726
|
+
- test-results.json
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
### Jenkins Pipeline Example
|
|
1730
|
+
|
|
1731
|
+
```groovy
|
|
1732
|
+
pipeline {
|
|
1733
|
+
agent any
|
|
1734
|
+
|
|
1735
|
+
environment {
|
|
1736
|
+
SN_INSTANCE = credentials('servicenow-instance')
|
|
1737
|
+
SN_CREDENTIALS = credentials('servicenow-credentials')
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
stages {
|
|
1741
|
+
stage('Setup') {
|
|
1742
|
+
steps {
|
|
1743
|
+
sh '''
|
|
1744
|
+
npm install -g @servicenow/sdk
|
|
1745
|
+
npm install -g @sonisoft/now-sdk-ext-cli
|
|
1746
|
+
export NOWSDK_INSTANCE=$SN_INSTANCE NOWSDK_USER=$SN_CREDENTIALS_USR NOWSDK_PASSWORD=$SN_CREDENTIALS_PSW
|
|
1747
|
+
now-sdk auth --add $SN_INSTANCE --type basic --alias jenkins
|
|
1748
|
+
'''
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
stage('Run Tests') {
|
|
1753
|
+
steps {
|
|
1754
|
+
sh '''
|
|
1755
|
+
nex atf --suite-id ${TEST_SUITE_ID} --auth jenkins --json > test-results.json
|
|
1756
|
+
'''
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
stage('Publish Results') {
|
|
1761
|
+
steps {
|
|
1762
|
+
archiveArtifacts artifacts: 'test-results.json'
|
|
1763
|
+
publishHTML([
|
|
1764
|
+
reportDir: '.',
|
|
1765
|
+
reportFiles: 'test-results.json',
|
|
1766
|
+
reportName: 'ATF Test Results'
|
|
1767
|
+
])
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
```
|
|
1773
|
+
|
|
1774
|
+
## ๐ก Examples
|
|
1775
|
+
|
|
1776
|
+
### Complete Workflow: Development to Production
|
|
1777
|
+
|
|
1778
|
+
```bash
|
|
1779
|
+
# 1. List available repository apps
|
|
1780
|
+
nex app:repo-list --installable --auth dev
|
|
1781
|
+
|
|
1782
|
+
# 2. Install application from repository
|
|
1783
|
+
nex app:repo-install --scope x_my_app --auth dev
|
|
1784
|
+
|
|
1785
|
+
# 3. Configure using REPL
|
|
1786
|
+
nex exec x_my_app --auth dev
|
|
1787
|
+
sn> gs.setProperty('x_my_app.api_key', 'dev_key_123');
|
|
1788
|
+
... .exec
|
|
1789
|
+
|
|
1790
|
+
# 4. Run tests
|
|
1791
|
+
nex atf --suite-name "My App Tests" --auth dev --wait
|
|
1792
|
+
|
|
1793
|
+
# 5. Deploy to production with parameterized script
|
|
1794
|
+
nex exec global ./deploy.js \
|
|
1795
|
+
--auth prod \
|
|
1796
|
+
--params '{"env":"production","api_key":"prod_key_456"}'
|
|
1797
|
+
|
|
1798
|
+
# 6. Verify deployment
|
|
1799
|
+
nex atf --suite-name "Smoke Tests" --auth prod --json > results.json
|
|
1800
|
+
```
|
|
1801
|
+
|
|
1802
|
+
### ATF Testing Examples
|
|
1803
|
+
|
|
1804
|
+
```bash
|
|
1805
|
+
# Execute a single test
|
|
1806
|
+
nex atf --test-id f717a8c783103210621e78c6feaad396 --auth dev
|
|
1807
|
+
|
|
1808
|
+
# Execute a test suite and wait for results
|
|
1809
|
+
nex atf --suite-id e077e00b83103210621e78c6feaad383 --auth dev --wait
|
|
1810
|
+
|
|
1811
|
+
# Execute by name (no need to look up sys_id)
|
|
1812
|
+
nex atf --suite-name "Regression Tests" --auth dev
|
|
1813
|
+
|
|
1814
|
+
# Performance test with specific browser
|
|
1815
|
+
nex atf --suite-id abc123 --browser chrome --performance --auth dev
|
|
1816
|
+
|
|
1817
|
+
# CI/CD integration with JSON output
|
|
1818
|
+
nex atf --suite-name "CI Tests" --auth ci --json > test-results.json
|
|
1819
|
+
|
|
1820
|
+
# Custom polling for long tests
|
|
1821
|
+
nex atf --suite-id xyz789 --poll-interval 10000 --auth dev
|
|
1822
|
+
```
|
|
1823
|
+
|
|
1824
|
+
### Application Management Examples
|
|
1825
|
+
|
|
1826
|
+
```bash
|
|
1827
|
+
# Browse company repository
|
|
1828
|
+
nex app:repo-list --auth prod
|
|
1829
|
+
nex app:repo-list --installable --json --auth prod
|
|
1830
|
+
|
|
1831
|
+
# Install from repository
|
|
1832
|
+
nex app:repo-install --scope x_custom_app --auth prod
|
|
1833
|
+
nex app:repo-install --scope x_custom_app --version 2.0.0 --auth prod
|
|
1834
|
+
nex app:repo-install --scope x_custom_app --no-wait --auth prod
|
|
1835
|
+
|
|
1836
|
+
# Batch install multiple apps
|
|
1837
|
+
nex app:install --batch --definitionPath ./production-apps.json --auth prod
|
|
1838
|
+
|
|
1839
|
+
# Uninstall application
|
|
1840
|
+
nex app:uninstall -i a1b2c3d4e5f6 -s x_my_app --auth dev
|
|
1841
|
+
```
|
|
1842
|
+
|
|
1843
|
+
### Script Execution Examples
|
|
1844
|
+
|
|
1845
|
+
#### File Mode
|
|
1846
|
+
```bash
|
|
1847
|
+
# Execute script file
|
|
1848
|
+
nex exec global ./cleanup.js --auth dev
|
|
1849
|
+
|
|
1850
|
+
# Execute in custom scope
|
|
1851
|
+
nex exec x_my_app ./app-setup.js --auth dev
|
|
1852
|
+
|
|
1853
|
+
# Pipe output
|
|
1854
|
+
nex exec global ./report.js --auth dev > report.txt
|
|
1855
|
+
nex exec global ./list-users.js --auth dev | grep "admin"
|
|
1856
|
+
```
|
|
1857
|
+
|
|
1858
|
+
#### REPL Mode
|
|
1859
|
+
```bash
|
|
1860
|
+
# Start REPL
|
|
1861
|
+
$ nex exec global --auth dev
|
|
1862
|
+
|
|
1863
|
+
# Execute multi-line scripts interactively
|
|
1864
|
+
sn> var gr = new GlideRecord('incident');
|
|
1865
|
+
... gr.addQuery('priority', 1);
|
|
1866
|
+
... gr.query();
|
|
1867
|
+
... gs.info('Critical incidents: ' + gr.getRowCount());
|
|
1868
|
+
... .exec
|
|
1869
|
+
|
|
1870
|
+
*** Script: Critical incidents: 5
|
|
1871
|
+
|
|
1872
|
+
sn> .exit
|
|
1873
|
+
```
|
|
1874
|
+
|
|
1875
|
+
#### Parameterized Scripts
|
|
1876
|
+
```bash
|
|
1877
|
+
# Single parameter
|
|
1878
|
+
nex exec global ./query-user.js \
|
|
1879
|
+
--auth dev \
|
|
1880
|
+
--params '{"username":"admin"}'
|
|
1881
|
+
|
|
1882
|
+
# Multiple parameters
|
|
1883
|
+
nex exec global ./deploy.js \
|
|
1884
|
+
--auth prod \
|
|
1885
|
+
--params '{"env":"production","token":"secret","debug":false,"timeout":30000}'
|
|
1886
|
+
|
|
1887
|
+
# From environment variables
|
|
1888
|
+
export API_TOKEN="secret_token"
|
|
1889
|
+
nex exec global ./api-call.js \
|
|
1890
|
+
--auth prod \
|
|
1891
|
+
--params "{\"token\":\"$API_TOKEN\",\"endpoint\":\"https://api.example.com\"}"
|
|
1892
|
+
```
|
|
1893
|
+
|
|
1894
|
+
### Batch Application Installation
|
|
1895
|
+
|
|
1896
|
+
Create a `batch-install.json` file:
|
|
1897
|
+
|
|
1898
|
+
```json
|
|
1899
|
+
{
|
|
1900
|
+
"applications": [
|
|
1901
|
+
{
|
|
1902
|
+
"name": "Core Application",
|
|
1903
|
+
"scope": "x_core_app",
|
|
1904
|
+
"version": "2.0.0",
|
|
1905
|
+
"load_demo_data": false,
|
|
1906
|
+
"notes": "Production release"
|
|
1907
|
+
},
|
|
1908
|
+
{
|
|
1909
|
+
"name": "Integration Module",
|
|
1910
|
+
"scope": "x_integration",
|
|
1911
|
+
"version": "1.5.0",
|
|
1912
|
+
"load_demo_data": false
|
|
1913
|
+
}
|
|
1914
|
+
]
|
|
1915
|
+
}
|
|
1916
|
+
```
|
|
1917
|
+
|
|
1918
|
+
Execute:
|
|
1919
|
+
|
|
1920
|
+
```bash
|
|
1921
|
+
nex app:install --batch --definitionPath ./batch-install.json --auth prod
|
|
1922
|
+
```
|
|
1923
|
+
|
|
1924
|
+
### Real-World Scenarios
|
|
1925
|
+
|
|
1926
|
+
#### Scenario 1: Daily Smoke Tests
|
|
1927
|
+
```bash
|
|
1928
|
+
#!/bin/bash
|
|
1929
|
+
# daily-tests.sh
|
|
1930
|
+
|
|
1931
|
+
nex atf \
|
|
1932
|
+
--suite-name "Daily Smoke Tests" \
|
|
1933
|
+
--auth prod \
|
|
1934
|
+
--json > test-results-$(date +%Y%m%d).json
|
|
1935
|
+
|
|
1936
|
+
if [ $? -eq 0 ]; then
|
|
1937
|
+
echo "โ All tests passed!"
|
|
1938
|
+
else
|
|
1939
|
+
echo "โ Tests failed!"
|
|
1940
|
+
exit 1
|
|
1941
|
+
fi
|
|
1942
|
+
```
|
|
1943
|
+
|
|
1944
|
+
#### Scenario 2: Environment Setup
|
|
1945
|
+
```bash
|
|
1946
|
+
#!/bin/bash
|
|
1947
|
+
# setup-environment.sh
|
|
1948
|
+
|
|
1949
|
+
# Install required apps from repository
|
|
1950
|
+
nex app:repo-install --scope x_core_app --auth new-env
|
|
1951
|
+
nex app:repo-install --scope x_integration --auth new-env
|
|
1952
|
+
|
|
1953
|
+
# Configure via parameterized script
|
|
1954
|
+
nex exec global ./configure.js \
|
|
1955
|
+
--auth new-env \
|
|
1956
|
+
--params '{"env":"staging","debug":true}'
|
|
1957
|
+
|
|
1958
|
+
# Validate with ATF
|
|
1959
|
+
nex atf --suite-name "Environment Validation" --auth new-env
|
|
1960
|
+
```
|
|
1961
|
+
|
|
1962
|
+
#### Scenario 3: Data Migration
|
|
1963
|
+
```bash
|
|
1964
|
+
#!/bin/bash
|
|
1965
|
+
# migrate-data.sh
|
|
1966
|
+
|
|
1967
|
+
# Export from source
|
|
1968
|
+
nex exec global ./export-data.js --auth source > data.json
|
|
1969
|
+
|
|
1970
|
+
# Transform data
|
|
1971
|
+
cat data.json | jq '.records' > transformed.json
|
|
1972
|
+
|
|
1973
|
+
# Import to target with parameters
|
|
1974
|
+
nex exec global ./import-data.js \
|
|
1975
|
+
--auth target \
|
|
1976
|
+
--params "{\"data\":\"$(cat transformed.json)\"}"
|
|
1977
|
+
|
|
1978
|
+
# Validate
|
|
1979
|
+
nex atf --suite-name "Data Validation" --auth target
|
|
1980
|
+
```
|
|
1981
|
+
|
|
1982
|
+
## ๐ง Troubleshooting
|
|
1983
|
+
|
|
1984
|
+
### Common Issues
|
|
1985
|
+
|
|
1986
|
+
#### Authentication Errors
|
|
1987
|
+
|
|
1988
|
+
```bash
|
|
1989
|
+
# List all configured authentication profiles
|
|
1990
|
+
now-sdk auth --list
|
|
1991
|
+
|
|
1992
|
+
# Delete and re-add credentials if needed
|
|
1993
|
+
now-sdk auth --delete your-alias
|
|
1994
|
+
now-sdk auth --add instance.service-now.com --type basic --alias your-alias
|
|
1995
|
+
|
|
1996
|
+
# Set as default
|
|
1997
|
+
now-sdk auth --use your-alias
|
|
1998
|
+
```
|
|
1999
|
+
|
|
2000
|
+
#### Command Not Found
|
|
2001
|
+
|
|
2002
|
+
```bash
|
|
2003
|
+
# Verify installation
|
|
2004
|
+
npm list -g @sonisoft/now-sdk-ext-cli
|
|
2005
|
+
|
|
2006
|
+
# Reinstall if needed
|
|
2007
|
+
npm install -g @sonisoft/now-sdk-ext-cli
|
|
2008
|
+
|
|
2009
|
+
# Check PATH includes npm global binaries
|
|
2010
|
+
npm config get prefix
|
|
2011
|
+
```
|
|
2012
|
+
|
|
2013
|
+
#### Test Execution Timeouts
|
|
2014
|
+
|
|
2015
|
+
```bash
|
|
2016
|
+
# Increase poll interval
|
|
2017
|
+
nex atf --suite-id xyz --auth dev --poll-interval 15000
|
|
2018
|
+
|
|
2019
|
+
# Check instance performance
|
|
2020
|
+
# Check test suite complexity
|
|
2021
|
+
# Review ServiceNow logs
|
|
2022
|
+
```
|
|
2023
|
+
|
|
2024
|
+
#### Permission Errors
|
|
2025
|
+
|
|
2026
|
+
```bash
|
|
2027
|
+
# Verify user has required roles:
|
|
2028
|
+
# - atf_test_runner for ATF operations
|
|
2029
|
+
# - admin for app management
|
|
2030
|
+
# - appropriate scope access for scripts
|
|
2031
|
+
```
|
|
2032
|
+
|
|
2033
|
+
### Debug Mode
|
|
2034
|
+
|
|
2035
|
+
Enable debug logging for detailed troubleshooting:
|
|
2036
|
+
|
|
2037
|
+
```bash
|
|
2038
|
+
nex atf --test-id xyz --auth dev --log-level debug
|
|
2039
|
+
```
|
|
2040
|
+
|
|
2041
|
+
### Getting Help
|
|
2042
|
+
|
|
2043
|
+
```bash
|
|
2044
|
+
# General help
|
|
2045
|
+
nex --help
|
|
2046
|
+
|
|
2047
|
+
# Command-specific help
|
|
2048
|
+
nex atf --help
|
|
2049
|
+
nex app --help
|
|
2050
|
+
nex exec --help
|
|
2051
|
+
```
|
|
2052
|
+
|
|
2053
|
+
## ๐ Best Practices
|
|
2054
|
+
|
|
2055
|
+
### Security
|
|
2056
|
+
|
|
2057
|
+
- **Never commit credentials** to version control
|
|
2058
|
+
- Use environment variables or secure credential stores in CI/CD
|
|
2059
|
+
- Regularly rotate passwords
|
|
2060
|
+
- Use least-privilege accounts for automation
|
|
2061
|
+
- Audit script execution logs
|
|
2062
|
+
|
|
2063
|
+
### Testing
|
|
2064
|
+
|
|
2065
|
+
- Always test scripts in development environments first
|
|
2066
|
+
- Use ATF for automated regression testing
|
|
2067
|
+
- Implement proper error handling in scripts
|
|
2068
|
+
- Validate batch installation definitions before production use
|
|
2069
|
+
|
|
2070
|
+
### CI/CD
|
|
2071
|
+
|
|
2072
|
+
- Use JSON output mode for parsing results
|
|
2073
|
+
- Check exit codes (0 = success, 1 = failure)
|
|
2074
|
+
- Archive test results as artifacts
|
|
2075
|
+
- Implement proper secret management
|
|
2076
|
+
- Use dedicated service accounts
|
|
2077
|
+
|
|
2078
|
+
### Performance
|
|
2079
|
+
|
|
2080
|
+
- Adjust poll intervals based on test duration
|
|
2081
|
+
- Use batch operations when possible
|
|
2082
|
+
- Monitor instance performance during test execution
|
|
2083
|
+
- Consider off-peak hours for large operations
|
|
2084
|
+
|
|
2085
|
+
## ๐ Documentation
|
|
2086
|
+
|
|
2087
|
+
### Comprehensive Guides
|
|
2088
|
+
|
|
2089
|
+
| Guide | Description |
|
|
2090
|
+
|-------|-------------|
|
|
2091
|
+
| [Getting Started](./docs/GETTING_STARTED.md) | Complete setup and first steps guide |
|
|
2092
|
+
| [REPL Mode](./docs/REPL_MODE.md) | Interactive script executor documentation |
|
|
2093
|
+
| [Script Parameterization](./docs/SCRIPT_PARAMETERIZATION.md) | Template scripts with parameter replacement |
|
|
2094
|
+
| [Autocomplete Setup](./docs/AUTOCOMPLETE.md) | Full autocomplete documentation |
|
|
2095
|
+
| [Autocomplete Quick Start](./docs/AUTOCOMPLETE_QUICKSTART.md) | 3-step setup guide |
|
|
2096
|
+
| [ATF Command](./docs/ATF_COMMAND.md) | Detailed ATF testing documentation |
|
|
2097
|
+
| [Summary](./docs/SUMMARY.md) | Feature overview and capabilities |
|
|
2098
|
+
|
|
2099
|
+
### Quick References
|
|
2100
|
+
|
|
2101
|
+
```bash
|
|
2102
|
+
# Command-specific help
|
|
2103
|
+
nex --help
|
|
2104
|
+
nex atf --help
|
|
2105
|
+
nex app --help
|
|
2106
|
+
nex app:repo-list --help
|
|
2107
|
+
nex app:repo-install --help
|
|
2108
|
+
nex app:uninstall --help
|
|
2109
|
+
nex exec --help
|
|
2110
|
+
|
|
2111
|
+
# Enable autocomplete
|
|
2112
|
+
nex autocomplete
|
|
2113
|
+
```
|
|
2114
|
+
|
|
2115
|
+
### API Reference
|
|
2116
|
+
|
|
2117
|
+
All commands are built on `@sonisoft/now-sdk-ext-core`. For low-level API documentation:
|
|
2118
|
+
- [Core Library Documentation](https://www.npmjs.com/package/@sonisoft/now-sdk-ext-core)
|
|
2119
|
+
- [ServiceNow SDK Documentation](https://www.servicenow.com/docs/bundle/zurich-application-development/page/build/servicenow-sdk/reference/servicenow-sdk-cli-commands.html)
|
|
2120
|
+
|
|
2121
|
+
---
|
|
2122
|
+
|
|
2123
|
+
## ๐ Support & Contributing
|
|
2124
|
+
|
|
2125
|
+
### Getting Help
|
|
2126
|
+
|
|
2127
|
+
- ๐ **Documentation**: Start with [Getting Started Guide](./docs/GETTING_STARTED.md)
|
|
2128
|
+
- ๐ฌ **Issues**: [GitHub Issues](https://github.com/sonisoft/now-sdk-ext-cli/issues)
|
|
2129
|
+
- ๐ฆ **NPM**: [@sonisoft/now-sdk-ext-cli](https://www.npmjs.com/package/@sonisoft/now-sdk-ext-cli)
|
|
2130
|
+
- โ **Questions**: Open a GitHub Discussion
|
|
2131
|
+
|
|
2132
|
+
### Contributing
|
|
2133
|
+
|
|
2134
|
+
Contributions are welcome! We appreciate:
|
|
2135
|
+
|
|
2136
|
+
- ๐ Bug reports and fixes
|
|
2137
|
+
- โจ Feature requests and implementations
|
|
2138
|
+
- ๐ Documentation improvements
|
|
2139
|
+
- ๐งช Additional test coverage
|
|
2140
|
+
- ๐ก Usage examples and tutorials
|
|
2141
|
+
|
|
2142
|
+
#### Development Setup
|
|
2143
|
+
|
|
2144
|
+
```bash
|
|
2145
|
+
# Clone the repository
|
|
2146
|
+
git clone https://github.com/sonisoft/now-sdk-ext-cli.git
|
|
2147
|
+
cd now-sdk-ext-cli
|
|
2148
|
+
|
|
2149
|
+
# Install dependencies
|
|
2150
|
+
npm install
|
|
2151
|
+
|
|
2152
|
+
# Build
|
|
2153
|
+
npm run build
|
|
2154
|
+
|
|
2155
|
+
# Run tests (48 unit tests)
|
|
2156
|
+
npm test
|
|
2157
|
+
|
|
2158
|
+
# Run linter
|
|
2159
|
+
npm run lint
|
|
2160
|
+
|
|
2161
|
+
# Test locally
|
|
2162
|
+
./bin/run.js exec global --auth your-instance
|
|
2163
|
+
```
|
|
2164
|
+
|
|
2165
|
+
#### Running Tests
|
|
2166
|
+
|
|
2167
|
+
```bash
|
|
2168
|
+
# All tests
|
|
2169
|
+
npm test
|
|
2170
|
+
|
|
2171
|
+
# Specific test file
|
|
2172
|
+
npm test -- test/commands/exec/parameterization.test.ts
|
|
2173
|
+
|
|
2174
|
+
# With coverage
|
|
2175
|
+
npm test -- --coverage
|
|
2176
|
+
```
|
|
2177
|
+
|
|
2178
|
+
---
|
|
2179
|
+
|
|
2180
|
+
## ๐ License
|
|
2181
|
+
|
|
2182
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
2183
|
+
|
|
2184
|
+
## ๐ Related Projects
|
|
2185
|
+
|
|
2186
|
+
- [@servicenow/sdk](https://www.npmjs.com/package/@servicenow/sdk) - Official ServiceNow SDK
|
|
2187
|
+
- [@sonisoft/now-sdk-ext-core](https://www.npmjs.com/package/@sonisoft/now-sdk-ext-core) - Core library powering this CLI
|
|
2188
|
+
|
|
2189
|
+
---
|
|
2190
|
+
|
|
2191
|
+
## โญ Why Choose `nex`?
|
|
2192
|
+
|
|
2193
|
+
### vs. Manual ServiceNow UI
|
|
2194
|
+
|
|
2195
|
+
| Task | Manual UI | With `nex` |
|
|
2196
|
+
|------|-----------|------------|
|
|
2197
|
+
| Run 10 ATF tests | Click each test, wait, check results (30+ min) | `nex atf --suite-id xyz --json` (5 min) |
|
|
2198
|
+
| Install 5 apps | Navigate, click, wait for each (20+ min) | `nex app:install --batch apps.json` (10 min) |
|
|
2199
|
+
| Test a script idea | Create file, upload, run, download (5 min) | `nex exec global` type & run (30 sec) |
|
|
2200
|
+
| Deploy to 3 envs | Repeat manually 3 times (1+ hour) | `./deploy.sh` with params (15 min) |
|
|
2201
|
+
|
|
2202
|
+
### vs. ServiceNow REST API
|
|
2203
|
+
|
|
2204
|
+
| Feature | REST API | With `nex` |
|
|
2205
|
+
|---------|----------|------------|
|
|
2206
|
+
| Authentication | Manage yourself | Uses ServiceNow SDK (secure keychain) |
|
|
2207
|
+
| ATF Execution | Complex multi-step process | Single command |
|
|
2208
|
+
| Progress Monitoring | Manual polling | Automatic with progress display |
|
|
2209
|
+
| Error Handling | Parse HTTP responses | Clear error messages |
|
|
2210
|
+
| Output Formatting | Parse JSON yourself | Beautiful console or JSON mode |
|
|
2211
|
+
|
|
2212
|
+
### vs. Other Tools
|
|
2213
|
+
|
|
2214
|
+
- โ
**Built for ServiceNow**: Purpose-built, not a generic tool adapted for ServiceNow
|
|
2215
|
+
- โ
**Modern CLI**: Uses industry-standard oclif framework
|
|
2216
|
+
- โ
**Extensible**: Plugin support for custom commands
|
|
2217
|
+
- โ
**Well-Tested**: 48+ unit tests, production-ready
|
|
2218
|
+
- โ
**Actively Maintained**: Regular updates and improvements
|
|
2219
|
+
- โ
**Open Source**: MIT licensed, community-driven
|
|
2220
|
+
|
|
2221
|
+
### What Makes It Special
|
|
2222
|
+
|
|
2223
|
+
1. **๐จ Interactive REPL**: Only CLI with interactive ServiceNow script execution
|
|
2224
|
+
2. **๐ฏ Smart Autocomplete**: Only CLI that queries your instance for scopes
|
|
2225
|
+
3. **๐ Parameterization**: Template scripts for any environment
|
|
2226
|
+
4. **๐ฆ Repository Integration**: Direct company repository access
|
|
2227
|
+
5. **๐ Complete Lifecycle**: From installation to testing to uninstallation
|
|
2228
|
+
6. **๐ DevOps First**: Built for automation, CI/CD, and modern workflows
|
|
2229
|
+
|
|
2230
|
+
---
|
|
2231
|
+
|
|
2232
|
+
Made with โค๏ธ for the ServiceNow Developer Community
|
|
2233
|
+
|
|
2234
|
+
**Ready to get started?** โ [Jump to Quick Start](#-quick-start)
|