Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #25 from zvercodebender/master
Browse files Browse the repository at this point in the history
create ticket using a JSON object
  • Loading branch information
Rick Broker committed Oct 26, 2017
2 parents dddddaf + bfcda58 commit 2ec6f6b
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,8 @@ deploy:
provider: releases
api_key:
secure: MDy/R3WGvW3rGg9YEEBzGkZtKMK8EEwR/+xoX2ynXrEKGGiXEmCLeJ1i+X5v1N+Wn7y86t9zkwBtMRgWDbHOQMPRv+XcBpJXIKbS+KSkzKbDVEBk9m8Qh8XxhSDUWhjIBiVfUe4/jrEVHE9vIXGFoikLMf9IQyLgeOEkLDLs6ag=
file: build/libs/xlr-servicenow-plugin-4.1.11.jar
file_glob: true
file: build/libs/*
skip_cleanup: true
on:
all_bracnhes: true
Expand Down
19 changes: 18 additions & 1 deletion README.md
Expand Up @@ -48,6 +48,12 @@ The ServiceNow plugin integrates with the SNOW REST API v1 (i.e. `/api/now/v1/`)

![image](images/CreateChangeRequest.png)

This task will return the system ID of the change request as well as the change ticket ID. These items can be used later in your release to interact with this ticket.

+ **Create New Change Request** - This task will create a change request in ServiceNow.

![image](images/CreateNewChangeRequest.png)

This task will return the system ID of the change request as well as the change ticket ID. These items can be used later in your release to interact with this ticket.
+ **Update Record** - This task can be used to make changes to change requests.
Expand Down Expand Up @@ -96,6 +102,10 @@ The ServiceNow plugin integrates with the SNOW REST API v1 (i.e. `/api/now/v1/`)

![image](images/CreateIncident.png)

+ **Create New Incident** - This task will create a new incident.

![image](images/CreateNewIncident.png)

+ **Update Incident** - This task will update an existing incident

![image](images/UpdateIncident.png)
Expand All @@ -110,6 +120,10 @@ The ServiceNow plugin integrates with the SNOW REST API v1 (i.e. `/api/now/v1/`)

![image](images/CreateServiceRequest.png)

+ **Create New Service Request Item** - This task will create a service request.

![image](images/CreateNewServiceRequest.png)


+ **Update Service Request Item** - Update an existing service request item

Expand All @@ -124,9 +138,12 @@ The ServiceNow plugin integrates with the SNOW REST API v1 (i.e. `/api/now/v1/`)
### Service Request Items ###

+ **Create Service Request Item** - This task will create a service request item. It expects that there is already a service request opened that this item can be attached to.

![image](images/CreateRequestItem.png)

+ **Create New Service Request Item** - This task will create a service request item. It expects that there is already a service request opened that this item can be attached to.
![image](images/CreateNewRequestItem.png)


+ **Update Service Request Item** - Update an existing service request item

![image](images/UpdateRequestItem.png)
Expand Down
20 changes: 19 additions & 1 deletion build.gradle
@@ -1,14 +1,17 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id "com.github.hierynomus.license" version "0.14.0"
id "com.xebialabs.xl.docker" version "1.1.0"
id "nebula.release" version "6.0.0"
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'

version = '4.1.11'
//version = '4.1.11'

xlDocker {
compileImage = 'xebialabs/xlr_dev_compile'
Expand All @@ -18,6 +21,21 @@ xlDocker {
runPortMapping = '15516:5516'
}

if (!project.hasProperty('release.scope')) {
project.ext['release.scope'] = 'patch'
}

if (!project.hasProperty('release.useLastTag')) {
project.ext['release.useLastTag'] = true
}

processResources.configure {
filter ReplaceTokens, tokens: [
'project.version': version.toString(),
'project.name' : rootProject.name
]
}

license {
header rootProject.file('License.md')
strictCheck false
Expand Down
Binary file added images/CreateNewChangeRequest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/CreateNewIncident.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/CreateNewRequestItem.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/CreateNewServiceRequest.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions src/main/resources/servicenow/CreateNewRecord.py
@@ -0,0 +1,43 @@
#
# Copyright 2017 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#


import sys, time, traceback
from servicenow.ServiceNowClient import ServiceNowClient

if servicenowServer is None:
print "No server provided."
sys.exit(1)

if tableName is None:
print "No tableName provided."
sys.exit(1)

snClient = ServiceNowClient.create_client(servicenowServer, username, password)

print "Sending content %s" % content

try:
data = snClient.create_record( tableName, content )
sysId = data["sys_id"]
Ticket = data["number"]
print "Created %s in Service Now." % (sysId)
print "Created %s in Service Now." % (Ticket)
print "\n"
print snClient.print_record( data )
except Exception, e:
exc_info = sys.exc_info()
traceback.print_exception( *exc_info )
print e
print snClient.print_error( e )
print "Failed to create record in Service Now"
sys.exit(1)


2 changes: 1 addition & 1 deletion src/main/resources/servicenow/CreateRecord.py
Expand Up @@ -11,7 +11,7 @@

import sys, time
import com.xhaus.jyson.JysonCodec as json
from servicenow.ServiceNowClient import ServiceNowClient
#from servicenow.ServiceNowClient import ServiceNowClient

if servicenowServer is None:
print "No server provided."
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/servicenow/PollingCheckStatus.py
Expand Up @@ -36,7 +36,7 @@
try:
data = sn_client.get_change_request(tableName, sysId)
status = data[statusField]
print "Found [%s] in Service Now with status: [%s]\n" % (sysId, status)
print "Found [%s] in Service Now with status: [%s] Looking for %s\n" % (data['number'], status, checkForStatus)
if status == checkForStatus:
status = data[statusField]
ticket = data["number"]
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/servicenow/RequestApproval.py
Expand Up @@ -65,7 +65,7 @@

status = data["approval"]
print "Found %s in Service Now as %s" % (data['number'], status)
if "approved" == status:
if "Approved" == status:
approval = False
isClear = True
print "ServiceNow approval received."
Expand Down
31 changes: 31 additions & 0 deletions src/main/resources/synthetic.xml
Expand Up @@ -46,6 +46,17 @@
<property name="Ticket" category="output"/>
</type>

<type type="servicenow.CreateNewRecord" extends="servicenow.Task">
<property name="scriptLocation" default="servicenow/CreateNewRecord.py" hidden="true"/>

<property name="tableName" category="input" label="Table Name" default="change_request" required="true"
hidden="true"/>
<property name="content" category="input" label="Request Content" required="true" size="large"/>
<property name="sysId" category="output"/>
<property name="Ticket" category="output"/>

</type>

<type type="servicenow.UpdateRecord" extends="servicenow.Task">
<property name="scriptLocation" default="servicenow/UpdateRecord.py" hidden="true"/>

Expand Down Expand Up @@ -101,6 +112,11 @@
hidden="true"/>
</type>

<type type="servicenow.CreateNewChangeRequest" extends="servicenow.CreateNewRecord">
<property name="tableName" category="input" label="Table Name" default="change_request" required="true"
hidden="true"/>
</type>

<type type="servicenow.UpdateChangeRequest" extends="servicenow.UpdateRecord">
<property name="tableName" category="input" label="Table Name" default="change_request" required="true"
hidden="true"/>
Expand Down Expand Up @@ -206,6 +222,11 @@
hidden="true"/>
</type>

<type type="servicenow.CreateNewIncident" extends="servicenow.CreateNewRecord">
<property name="tableName" category="input" label="Table Name" default="incident" required="true"
hidden="true"/>
</type>

<type type="servicenow.UpdateIncident" extends="servicenow.UpdateRecord">
<property name="tableName" category="input" label="Table Name" default="incident" required="true"
hidden="true"/>
Expand All @@ -226,6 +247,11 @@
hidden="true"/>
</type>

<type type="servicenow.CreateNewServiceRequest" extends="servicenow.CreateNewRecord">
<property name="tableName" category="input" label="Table Name" default="sc_request" required="true"
hidden="true"/>
</type>

<type type="servicenow.UpdateServiceRequest" extends="servicenow.UpdateRecord">
<property name="tableName" category="input" label="Table Name" default="sc_request" required="true"
hidden="true"/>
Expand All @@ -246,6 +272,11 @@
hidden="true"/>
</type>

<type type="servicenow.CreateNewRequestItem" extends="servicenow.CreateNewRecord">
<property name="tableName" category="input" label="Table Name" default="sc_req_item" required="true"
hidden="true"/>
</type>

<type type="servicenow.UpdateRequestItem" extends="servicenow.UpdateRecord">
<property name="tableName" category="input" label="Table Name" default="sc_req_item" required="true"
hidden="true"/>
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/docker/initialize/data/server-configs.json
Expand Up @@ -12,8 +12,8 @@
"id": "Configuration/Custom/Configuration2139581",
"type":"servicenow.Server",
"title":"servicenow",
"url":"https://servicenowcd.service-now.com/",
"url":"https://ven01142.service-now.com/",
"username":"admin",
"password":"admin",
"password":"t67XC.VqzyZ)",
}
]

0 comments on commit 2ec6f6b

Please sign in to comment.