2017-07-21 6 views
0

Team Foundation ServerでTrelloサービスフックを使用しようとしています。 The Description I Triedサービスからイベントのほとんどすべての情報を取得できないフック

このイベントJSONですが:

{ 
    "id": "03c164c2-8912-4d5e-8009-3707d5f83734", 
    "eventType": "git.push", 
    "publisherId": "tfs", 
    "scope": 0, 
    "message": { 
     "text": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.", 
     "html": "Jamal Hartnett pushed updates to Fabrikam-Fiber-Git:master.", 
     "markdown": "Jamal Hartnett pushed updates to `Fabrikam-Fiber-Git`:`master`." 
    }, 
    "detailedMessage": { 
     "text": "Jamal Hartnett pushed a commit to Fabrikam-Fiber-Git:master.\n - Fixed bug in web.config file 33b55f7c", 
     "html": "Jamal Hartnett pushed a commit to <a href=\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/\">Fabrikam-Fiber-Git</a>:<a href=\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/#version=GBmaster\">master</a>.\n<ul>\n<li>Fixed bug in web.config file <a href=\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74\">33b55f7c</a>\n</ul>", 
     "markdown": "Jamal Hartnett pushed a commit to [Fabrikam-Fiber-Git](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/):[master](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/#version=GBmaster).\n* Fixed bug in web.config file [33b55f7c](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74)" 
    }, 
    "resource": { 
     "commits": [ 
      { 
       "commitId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74", 
       "author": { 
        "name": "Jamal Hartnett", 
        "email": "[email protected]", 
        "date": "2015-02-25T19:01:00Z" 
       }, 
       "committer": { 
        "name": "Jamal Hartnett", 
        "email": "[email protected]", 
        "date": "2015-02-25T19:01:00Z" 
       }, 
       "comment": "Fixed bug in web.config file", 
       "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git/commit/33b55f7cb7e7e245323987634f960cf4a6e6bc74" 
      } 
     ], 
     "refUpdates": [ 
      { 
       "name": "refs/heads/master", 
       "oldObjectId": "aad331d8d3b131fa9ae03cf5e53965b51942618a", 
       "newObjectId": "33b55f7cb7e7e245323987634f960cf4a6e6bc74" 
      } 
     ], 
     "repository": { 
      "id": "278d5cd2-584d-4b63-824a-2ba458937249", 
      "name": "Fabrikam-Fiber-Git", 
      "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249", 
      "project": { 
       "id": "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c", 
       "name": "Fabrikam-Fiber-Git", 
       "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c", 
       "state": "wellFormed", 
       "visibility": "unchanged" 
      }, 
      "defaultBranch": "refs/heads/master", 
      "remoteUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_git/Fabrikam-Fiber-Git" 
     }, 
     "pushedBy": { 
      "id": "[email protected]", 
      "displayName": "Jamal Hartnett", 
      "uniqueName": "Windows Live ID\\[email protected]" 
     }, 
     "pushId": 14, 
     "date": "2014-05-02T19:17:13.3309587Z", 
     "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/git/repositories/278d5cd2-584d-4b63-824a-2ba458937249/pushes/14" 
    }, 
    "resourceVersion": "1.0", 
    "resourceContainers": { 
     "collection": { 
      "id": "c12d0eb8-e382-443b-9f9c-c52cba5014c2" 
     }, 
     "account": { 
      "id": "f844ec47-a9db-4511-8281-8b63f4eaf94e" 
     }, 
     "project": { 
      "id": "be9b3917-87e6-42a4-a549-2bc06a7a878f" 
     } 
    }, 
    "createdDate": "2017-07-21T16:48:44.312Z" 
} 

これだったの要求である私は、イベントJSONから必要な情報を得ることができない、私はfollowed this tutorial持っているとの接続は問題なく働いていたが、 Trelloに送信してください:

Method: POST 
URI: https://api.trello.com/1/cards?key=7d6630fd03ac2b6fc9fde2f2ef0c4096&token=******** 
HTTP Version: 1.1 
Headers: 
{ 
    Content-Type: application/json; charset=utf-8 
} 
Content: 
{ 
    "name": "Test Nº ", 
    "desc": "Description: ", 
    "pos": "top", 
    "due": null, 
    "labels": "green", 
    "idList": "5935a0d45ff8e5a6c8f828b9" 
} 

イベントJSONから取得/読み取ることができる唯一のフィールドは「メッセージ」です。

私は間違っていますか?

+0

?私はどこでこれを変えることができないのか分かりませんでした。 – VGs

+0

誤解をおかけして申し訳ありませんが、あなたと同じ結果を得ました。この場合、間違ったプレースホルダを使用しているようです。送信リクエストによると、 'resource.pushID'&' resource.commits。[0] .comment'は、発生したイベントの値に置き換えられません。しかし、 'git.xx''code.xx'のような複数のプレースホルダを試しましたが、これはうまくいきませんでしたが、他のイベントではbuild.id/workitem.idとうまく動作します。 codepushイベントでは、message/detailedmessage以外の情報を得ることができないか、フォーマットがハードコードになってしまうのではないかと心配です。 –

+0

フォーマットがハードコード化されていることを確認する方法と情報を入手する方法はどこで知ることができますか?私はなぜ彼らが簡単なことをとても難しくするのかを知りません。 – VGs

答えて

0

あなたがプッシュIDとコメントを取得したい場合は、説明がある:私はTFSアドレスを変更し、IDをコミットすることができます

{{push.pushId}} 

{{push.commits[0].comment}} 
+0

ありがとうございます、問題なく動作しました。 – VGs

0

更新

エディは、右のあなたは、この場合のリソースとしてpushを使用する必要があります。ドキュメントはあまり明確ではありません。結局、それはとても単純なものでした。しかし対応するcheckinのコードでチェックされていませんイベントでチェックされています。

この混乱を避けるために適用された各イベントのリソースがどのようになっているかは、明らかに明らかになります。


プレースホルダの基本的な形態は リソースは、リソースの名前(ETC、ビルド、ワークアイテム)イベントを高め、フィールドは、のリソースセクション内のフィールドである{{resource.field}}あります イベントID:サブスクリプションが完了し、ビルド、 のためだったのであれば、それはのようなものかもしれません:

Build {{build.id}} completed at {{build.finishTime}} 

問題は、あなたがこのケースで間違ったプレースホルダを使用しているようです。あなたの送信依頼によると、発生したイベントの値は、resource.pushID & resource.commits.[0].commentに置き換えられません。

+0

ありがとうございます。 – VGs

関連する問題