ServiceNow CLIを試してみる
version: Paris(Quebec?)
※ (2021-05)インストールは成功しましたがコマンドの実行には失敗しています…
SeviceNowをクライアントマシンから操作出来るServiceNow CLIというものがあると知ったのでWindows 10 Home 64bitマシンで試します以下はドキュメントの翻訳です
https://docs.servicenow.com/bundle/quebec-application-development/page/build/servicenow-cli/concept/servicenow-cli.html#
ServiceNow CLIのダウンロード
ServiceNow Storeでクライアント用のアプリケーションを落としてインストールする必要がありそうです(ドキュメントはQuebecしか見当たりませんでしたがStoreの互換性バージョンを確認するとQuebec, Paris, Orlandoとなってます)
Downloadをクリックすると認証ダイアログが表示されます
ServiceNow IDを持っている(HIに登録されている?)場合"Login via sign-on(SSO)"をクリックしてメールアドレス, パスワードで認証後にメールで送られる6桁の数字を入力, 登録していない場合は"Are you customer who doesn't have ServiceNow ID?"をクリックでメールアドレスとメールで送られてくる32桁の英数字とインスタンス名を入力してダウンロードします(因みに"Are you a federal(連邦政府) customer?"はこの記事を読んでる人で該当する人がいるとも思えないのでパスします)
ServiceNow CLIのインストール
zipファイルがダウンロードされたので解答したところMacOS, Linux, Windows用のインストーラーが見受けられました
snc-1.1.0-windows-x64-installer.exeをダブルクリックして実行してWindows Defender?に警告を出されつつ進めるとSet Upダイアログが表示されました
[Next]して
acceptしてNextして
インストール先はそのままで[Next]して
PATHに追加のまま[Next]して
準備が出来たらしいので[Next]して
終わったらしいので[Finish]して
win + rで"cmd"と入力して[OK]でdos窓を立ち上げてsncコマンドを実行したところ以下のusageが表示されました
C:\*********>snc
Name
snc
Description
The ServiceNow Command Line Interface (CLI) is an extensible framework that enables users to communicate with an instance from any client machine using the command line.
Synopsis
snc <command-group> <command> [arguments]
To see a list of additional commands, first configure a default profile and then run "snc --help"
Available Commands
help : Help about any command
version : Show the version of the snc CLI client
For additional help information on a specific command, run "snc <command> --help"
Command Groups
configure : The configure command group lets you set, view, and remove properties used by the CLI.
extension : Manage and update CLI extensions.
To see a list of additional commands, run "snc <command-group> --help"
Arguments
-d, --debug Print logs to console
-h, --help Display detailed help information
--no-interactive Disable all interactive prompts when running commands
--no-verbose Disable printing user facing messages in console
-o, --output string Set the format for printing command output. The supported formats are json (default), yaml, table, text and none.
-p, --profile string Use a specific connection profile when executing a command. If you do not provide this argument, the CLI uses the default profile.
ServiceNow CLIの構成ファイル
構成ファイルが以下のパスにあるようなので
見てみたら無いので(.snc以下のディレクトリはsncコマンドを1回実行すると出来るようです)
C:\Users\********\.snc>dir
2021/05/22 09:29 <DIR> .
2021/05/22 09:29 <DIR> ..
2021/05/22 09:29 <DIR> .extensions
2021/05/22 09:29 <DIR> .logs
ドキュメントを参考に作ってみて
C:\Users\********\.snc>snc configure profile set
> Host: dev********
> Login method: Basic
> Username: admin
> Password: ********
> Default output format: JSON
Connection to https://dev********.service-now.com successful.
This instance does not support dynamic commands. Functionality will be limited.
Profile default has been saved
instanceがParisだったからかこのinstanceはdynamic commandをsupportしてない機能は限定されていると言われながら何んとか出来たようです
C:\Users\********\.snc>dir
2021/05/22 10:02 <DIR> .
2021/05/22 10:02 <DIR> ..
2021/05/22 10:02 77 .checksum.txt
2021/05/22 09:29 <DIR> .extensions
2021/05/22 09:29 <DIR> .logs
2021/05/22 10:02 201 config.json
コマンド実行
record createを試してみるもエラーになってしまいました(これがdynamic commandというやつなのか…?)
C:\Users\********\.snc>snc record create --table incident --data "{short_description: 'New Incident'}"
Error: unknown flag: --table
Quebecのinstanceを用意して試してみたいところですが…暫くは使えるinstanceが無さそうなので…ここまでで一旦止めておきます
Author And Source
この問題について(ServiceNow CLIを試してみる), 我々は、より多くの情報をここで見つけました https://qiita.com/20_percent_cooler/items/1c531ffbbb7bd4220dd8著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .