bmoers / sn-cicd-example-v3

Example implementation of https://github.com/bmoers/sn-cicd V3
10 stars 24 forks source link

RestClient post payload to the /run rest api, server console got error 'CICD.prototype.addStep Error: addStep, no run instance found. State: run.run : failed' #2

Closed gitlabbin closed 5 years ago

gitlabbin commented 5 years ago

Post a json payload to https://localhost:8443/run, client got 200 ok, but server console log show a lot of error

curl -X POST -k -H 'Content-Type: application/json; charset=utf-8' -H 'x-access-token: 1Tnt2bx9mrVjxMQDfjhvRAYxiL9ldQN5ITR6DtM8T6Pq8YLbEjwAd60vmUiTIvSE' -i https://localhost:8443/run --data '{
    "requestor": {
        "userName": "BC",
        "fullName": "BC",
        "email": "bc@email.com"
    },
    "updateSet": "87294fd0dbb12300f526d426ca961912",
    "application": {
        "id": "51s3foc6of5skpulzc6bidvn5c89xrp4",
        "name": "SN Application Name"
    },
    "git": {
        "repository": "sn-example",
        "remoteUrl": "https://github.com/gitlabbin/sn-example.git",
        "url": "https://github.com/gitlabbin/sn-example.git",
        "enabled": true,
        "pullRequestEnabled": true
    },
    "atf": {
        "updateSetOnly": false
    },
    "source": {
        "name": "https://dev59944.service-now.com/",
        "accessToken": "eXwdKi7z6OEkRYh9ljJNY7271S9jnJxyyyk0VmMQJFJejbG601A3jjMFQZDLcoruelEtxXffSSPZX7PDIc43wQ"
    },
    "master": {
        "name": null,
        "accessToken": null
    }
}'

Server console failed: "Requested URI does not represent any resource: /swre/cicd/updateset/87294fd0dbb12300f526d426ca961912",

[09:29:53.140] [ERROR] [19324]  CICD.prototype.addStep Error: addStep, no run instance found. State: run.run : failed
    at Promise.try (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/sn-cicd/lib/cicd.js:427:23)
    at tryCatcher (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/method.js:39:29)
    at CICD.addStep (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/sn-cicd/lib/cicd.js:422:27)
    at step (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/sn-cicd/lib/modules/run.js:22:21)
    at Promise.try.then (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/sn-cicd/lib/modules/run.js:56:20)
    at tryCatcher (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/promise.js:606:10)
    at Async._drainQueue (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/async.js:138:12)
    at Async._drainQueues (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/brianchen/my-wk/sn-cicd-example-v3/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (timers.js:632:19)
[09:29:53.174] [ERROR] [19324]  { name: 'StatusCodeError',
  statusCode: 400,
  message:
   '400 - {"error":{"message":"Requested URI does not represent any resource: /swre/cicd/updateset/87294fd0dbb12300f526d426ca961912","detail":null},"status":"failure"}',
  error:
   { error:
      { message:
         'Requested URI does not represent any resource: /swre/cicd/updateset/87294fd0dbb12300f526d426ca961912',
        detail: null },
     status: 'failure' }
bmoers commented 5 years ago

With version 3 the API has changed Post the payload in the structure like https://github.com/bmoers/sn-cicd-example-v3/blob/master/payload.json to https://localhost:8443/run

Also 'updateSet' and 'application' are mandatory to have the process start.

gitlabbin commented 5 years ago

@bmoers Thanks for your update, rest client send payload with http 200 OK, the job triggered, but on server console, we can see the job failed, please check the update information with this ticket.

any config wrong or work around please? Tried using: https://github.com/bmoers/sn-cicd-integration/blob/master/update_set/CICD%20Integration.xml, but failed to import this updateset

thanks BC

bmoers commented 5 years ago

V3 needs the US to be installed. What error did you get when you tried to import the update set?

gitlabbin commented 5 years ago

Preview failed:

change update_set/CICD Integration.xml, delete sys_auth_profile_basic_adbf2723db34e380432cfc600f96190e sys_auth_profile_basic_91a53b23db34e380432cfc600f96197f related xml part, made the preview pass and committed this updateset, not sure this way right or not

bmoers commented 5 years ago

please run npm update to get the latest version of sn-cicd. The default namespace has changed to 'devops'. You should have an https://dev59944.service-now.com/api/devops/cicd/updateset API

gitlabbin commented 5 years ago

Thanks, will try out

gitlabbin commented 5 years ago

👍 Great job, close this issue, @bmoers , thanks for you sort this out.