How Can We Help?
Search for answers or browse our knowledge base.
Update Entity from Any System (Generic Connector)
Overview
SyncNow enables information from any system to be published easily into work systems entities such as epic, feature, story or any other entity
The following article elaborates the process of Setting generic system adapter notifications.
Usage Examples
- Publish build information such build version into work system entities
- Link entities to build URL or mention the build URL in comments
- Publish security of code, work progress to work systems entities
- Update security status to entities mentioned in comments or a specific entity
- Create a security bug in the developer management work system
- Create a live and monitor live incidents from production systems
Step By Step Instructions
- Create a generic connector – Set the connector name ,image and base URL
- It is recommended to set an IP address to restrict connector webhooks into SyncNow only from IP | IP Range
- Create a DevOps Gate process for SonarQube Scan Status with configuration like on images below
- Set map for SyncNow virtual entity which will represent the generic data to an entity in target system, map can be different for every entity type.
And the for example the Jenkins groovy function to assist with sending the information in SyncNow API
@NonCPS
def getCommentsString() {
def list = []
def changeLogSets = currentBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
if (entry.msg != null) {
list.add("""${entry.commitId} on ${new Date(entry.timestamp)}: ${entry.msg.replaceAll("[\n\r]", " ")}""")
}
}
}
return list.join(',')
}
def PublishBuildInformation(){
//publish Build URL into comments
def commits = getCommentsString()
def payload = """
[
{
"eventRelativeURL": "/job/${JOB_NAME}/${env.BUILD_ID}",
"comments": "${commits}",
"commentLinkTitle": "Item Published in Build '${JOB_NAME}', version ${env.VERSION}.${env.BUILD_ID}"
}
]
"""
string responseComment = httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', authentication: 'SyncNow', requestBody: "${payload}", url: "https://<SyncNowServer>/api/v1.0/app/DevOpsGate/Enrich/<DevOpsGateProcessID>?action=comment"
println("Commment Entity Status: ${responseComment.status}")
println("Commment Entity Content: ${responseComment.content}")
//publish Build version number into a field in work system entity
def payloadVer = """
[
{
"fields": [
{
"key": "Param1",
"value": "${env.VERSION}.${env.BUILD_ID} "
}
],
"comments": "${commits}"
}
]
"""
//Publish build version
string responseVer = httpRequest acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', authentication: 'SyncNow', requestBody: "${payloadVer}", url: "https://<SyncNowURL>/api/v1.0/app/DevOpsGate/Enrich/<DevOpsGateProcessID>?action=update"
println("Commment Entity Status: ${responseVer.status}")
println("Commment Entity Content: ${responseVer.content}")
}
- Create custom parameter for example Param1, this parameter needs to be set a value in the post API payload in order to update | create | comment | Link to an entity.
- Navigate to the Configuration page and press the Create | Update an Entity button. Copy SyncNow API URL :
To Create an entity in target system the URL should be
{SyncNowBackend}/api/v1.0/app/DevOpsGate/Enrich/{DevOpsGateProcessID}?action=create
To Update and entity the URL should be
{SyncNowBackend}/api/v1.0/app/DevOpsGate/Enrich/{DevOpsGateProcessID}?action=update
To add a comment with a link The URL Should be in the following format
{SyncNowBackend}/api/v1.0/app/DevOpsGate/Enrich/{DevOpsGateProcessID}?action=comment |
To link a relative URL from the generic connector to the to an entity
{SyncNowBackend}/api/v1.0/app/DevOpsGate/LinkIt/{DevOpsGateProcessID} |
- Verify that the script is running and data is published to SyncNow