Skip to content

Commit

Permalink
Merge pull request #46 from keptn-sandbox/feature/44/cleanup
Browse files Browse the repository at this point in the history
#44 remove outdated configuration-change function, rename other function to delivery triggered
  • Loading branch information
christian-kreuzberger-dtx authored Oct 29, 2021
2 parents 5629df5 + 2c54404 commit 18a8377
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 79 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,7 @@ echo "Open Keptns Bridge: ${keptn_bridge}/trace/${keptnContext}"
// -------------------------------------------
// If you want Keptn to deploy, test and evaluate then we can simply inform Keptn about a new configuration (=container image) you have
// Typically you would use your Jenkins to build and push a container to your container registry. After that you notify Keptn about it
def keptnContext = keptn.sendConfigurationChangedEvent image:"docker.io/grabnerandi/simplenodeservice:3.0.0", labels : labels
echo "Open Keptns Bridge: ${keptn_bridge}/trace/${keptnContext}"
//Keptn 0.8.x uses the following for the Delivery Use Case
// -------------------------------------------
def keptnContext = keptn.sendConfigurationTriggeredEvent testStrategy:"${params.TestStrategy}", deploymentURI:"${params.DeploymentURI}"
def keptnContext = keptn.sendDeliveryTriggeredEvent testStrategy:"${params.TestStrategy}", deploymentURI:"${params.DeploymentURI}"
String keptn_bridge = env.KEPTN_BRIDGE
echo "Open Keptns Bridge: ${keptn_bridge}/trace/${keptnContext}"
Expand Down
77 changes: 4 additions & 73 deletions src/sh/keptn/Keptn.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -957,80 +957,11 @@ def sendTestTriggeredEvent(Map args) {
}

/**
* sendConfigurationChangedEvent(project, stage, service, image, [labels, keptn_endpoint, keptn_api_token])
* Example: sendConfigurationChangedEvent image:"docker.io/grabnerandi/simplenodeservice:3.0.0"
* sendDeliveryTriggeredEvent(project, stage, service, image, [labels, keptn_endpoint, keptn_api_token])
* Example: sendDeliveryTriggeredEvent
* Will trigger a full delivery workflow in keptn!
* changed to delivery.triggered for keptn 0.8.0
*/
def sendConfigurationChangedEvent(Map args) {
def keptnInit = keptnLoadFromInit(args)

/* String project, String stage, String service, String image, String tag */
String keptn_endpoint = keptnInit['keptn_endpoint']
String keptn_api_token = keptnInit['keptn_api_token']

def labels = args.containsKey('labels') ? args.labels : [:]

String project = keptnInit['project']
String stage = keptnInit['stage']
String service = keptnInit['service']
String image = args.containsKey("image") ? args.image : ""
String tag = args.containsKey("tag") ? args.tag : "${BUILD_NUMBER}"

echo "Sending a Configuration Change event to Keptn for ${project}.${stage}.${service} for image ${image}"

def requestBody = """{
| "data": {
| "project": "${project}",
| "service": "${service}",
| "stage": "${stage}",
| "configurationChange": {
| "values": {
| "image": "${image}"
| }
| },
| "deployment": {
| "deploymentstrategy": "direct"
| },
| "labels": {
| "buildId" : "${tag}",
| "jobname" : "${JOB_NAME}",
| "buildNumber": "${BUILD_NUMBER}",
| "joburl" : "${BUILD_URL}"
| }
| },
| "datacontenttype": "application/json",
| "source": "jenkins-library",
| "specversion": "1.0",
| "type": "sh.keptn.event.${stage}.delivery.triggered"
|}
""".stripMargin()

// lets add our custom labels
requestBody = addCustomLabels(requestBody, labels)

def response = httpRequest contentType: 'APPLICATION_JSON',
customHeaders: [[maskValue: true, name: 'x-token', value: "${keptn_api_token}"]],
httpMode: 'POST',
requestBody: requestBody,
responseHandle: 'STRING',
url: "${keptn_endpoint}/v1/event",
validResponseCodes: "100:404",
ignoreSslErrors: true


// write response to keptn.context.json & add to artifacts
def keptnContext = writeKeptnContextFiles(response)

return keptnContext
}
/**
* sendConfigurationTriggeredEvent(project, stage, service, image, [labels, keptn_endpoint, keptn_api_token])
* Example: sendConfigurationTriggeredEvent
* Will trigger a full delivery workflow in keptn!
* changed to delivery.triggered for keptn 0.8.0
*/
def sendConfigurationTriggeredEvent(Map args) {
def sendDeliveryTriggeredEvent(Map args) {
def keptnInit = keptnLoadFromInit(args)

/* String project, String stage, String service, String image, String tag */
Expand All @@ -1047,7 +978,7 @@ def sendConfigurationTriggeredEvent(Map args) {
String testStrategy = args.containsKey("testStrategy") ? args.testStrategy : ""
String tag = args.containsKey("tag") ? args.tag : "${BUILD_NUMBER}"

echo "Sending a Configuration triggered event to Keptn for ${project}.${stage}.${service}"
echo "Sending a delivery.triggered event to Keptn for ${project}.${stage}.${service}"

def requestBody = """{
| "data": {
Expand Down

0 comments on commit 18a8377

Please sign in to comment.