keptn-sandbox / slackbot-service

Slackbot to trigger evaluations of quality gates and receive results in Slack
Apache License 2.0
4 stars 2 forks source link

Trigger tests & evaluation #6

Closed jetzlstorfer closed 4 years ago

jetzlstorfer commented 4 years ago

Use the slackbot to trigger tests & evaluation by Keptn and return the result of the evaluation as a result in Slack.

Potential commands:

Actions the bot has to take:

  1. send a deployment finished event to the keptn api endpoint
  2. wait for a evaluation-done event (attention: only events with the correct keptncontext must be considered)
  3. post the evaluation-done event back to slack

Example payload to send from the bot to Keptn:

{
  "type": "sh.keptn.events.deployment-finished",
  "specversion": "0.2",
  "source": "https://github.com/keptn/keptn/helm-service",
  "id": "f2b878d3-03c0-4e8f-bc3f-454bc1b3d79d",
  "time": "2019-06-07T07:02:15.64489Z",
  "contenttype": "application/json",
  "data": {
    "project": "$PROJECT",
    "stage": "$STAGE",
    "service": "$SERVICE",
    "testStrategy": "$TESTSTRATEGY",
    "tag": "0.9.1",
    "image": "docker.io/keptnexamples/carts",
    "labels": {
      "testid": "12345",
      "buildnr": "build17",
      "runby": "JohnDoe"
    },
    "deploymentURI": "http://carts.sockshop-staging.svc.cluster.local"
  }
}

Issues to clarify

  1. How to retrieve the Keptn Context ID? Is this needed for a deployment-finished event?
agrimmer commented 4 years ago

Regarding your issue: If the cloudevent does not contain any Keptn Context ID, the API automatically generates one.

jetzlstorfer commented 4 years ago

Thanks for clarification!

jetzlstorfer commented 4 years ago

Some input from another project that is triggered tests in a Jenkins pipeline:

    def requestBody = """{
        |  "contenttype": "application/json",
        |  "data": {
        |    "deploymentURIPublic": "${deploymentURI}",
        |    "teststrategy" : "${testStrategy}",
        |    "project": "${project}",
        |    "service": "${service}",
        |    "stage": "${stage}",
        |    "image" : "${JOB_NAME}",
        |    "tag" : "${BUILD_NUMBER}",
        |    "labels": {
        |      "build" : "${BUILD_NUMBER}",
        |      "jobname" : "${JOB_NAME}",
        |      "joburl" : "${BUILD_URL}"
        |    }
        |  },
        |  "source": "performance-service",
        |  "specversion": "0.2",
        |  "type": "sh.keptn.events.deployment-finished"
        |}

source: https://github.com/keptn-sandbox/keptn-jenkins-library/blob/master/src/sh/keptn/Keptn.groovy