{"action":"created","comment":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/26672389","id":26672389,"diff_hunk":"@@ -27,17 +28,46 @@ def __init__(self, name, init_config, agentConfig):\n         AgentCheck.__init__(self, name, init_config, agentConfig)\n         self.high_watermarks = {}\n \n+    def _parse_timestamp(self, dir_name):\n+        if os.path.exists(os.path.join(dir_name, 'jenkins_build.tar.gz')):\n+            raise Skip('the build has already been archived', dir_name)\n+\n+        # Read the build.xml metadata file that Jenkins generates\n+        build_file = os.path.join(dir_name, 'build.xml')\n+\n+        if not os.access(build_file, os.R_OK):\n+            self.log.debug(\"Can't read build file at %s\" % (build_file))\n+            raise Exception(\"Can't access build.xml at %s\" % (build_file))\n+        else:\n+            tree = ElementTree()\n+            tree.parse(build_file)\n+            timestamp = tree.find('timestamp')\n+            if timestamp is None or not timestamp.text:\n+                raise Skip('the timestamp cannot be found', dir_name)\n+            else:\n+                return timestamp.text\n+\n     def _extract_timestamp(self, dir_name):\n         if not os.path.isdir(dir_name):\n             raise Skip('its not a build directory', dir_name)\n \n+        dir_basename = os.path.basename(dir_name)\n         try:\n-            # Parse the timestamp from the directory name\n-            date_str = os.path.basename(dir_name)\n-            time_tuple = time.strptime(date_str, self.datetime_format)\n-            return time.mktime(time_tuple)\n+            dir_basename = int(dir_basename)\n         except ValueError:\n-            raise Exception(\"Error with build directory name, not a parsable date: %s\" % (dir_name))\n+            pass\n+        if isinstance(dir_basename, int):\n+            # Parse the timestamp from the build.xml","path":"checks.d/jenkins.py","position":46,"original_position":46,"commit_id":"ce5334d2369b04e19f4e2fc09691ac98cca4fb4b","original_commit_id":"ce5334d2369b04e19f4e2fc09691ac98cca4fb4b","user":{"login":"hkaj","id":5287287,"avatar_url":"https://avatars.githubusercontent.com/u/5287287?v=3","gravatar_id":"","url":"https://api.github.com/users/hkaj","html_url":"https://github.com/hkaj","followers_url":"https://api.github.com/users/hkaj/followers","following_url":"https://api.github.com/users/hkaj/following{/other_user}","gists_url":"https://api.github.com/users/hkaj/gists{/gist_id}","starred_url":"https://api.github.com/users/hkaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkaj/subscriptions","organizations_url":"https://api.github.com/users/hkaj/orgs","repos_url":"https://api.github.com/users/hkaj/repos","events_url":"https://api.github.com/users/hkaj/events{/privacy}","received_events_url":"https://api.github.com/users/hkaj/received_events","type":"User","site_admin":false},"body":"We can, but the timestamp is also part of the event data (see https://github.com/DataDog/dd-agent/blob/master/checks.d/jenkins.py#L107). I can remove it if you think it isn't useful, but I think having a timestamp when looking at an event is always handy.","created_at":"2015-03-18T15:18:04Z","updated_at":"2015-03-18T15:18:04Z","html_url":"https://github.com/DataDog/dd-agent/pull/1442#discussion_r26672389","pull_request_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442","_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments/26672389"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1442#discussion_r26672389"},"pull_request":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442"}}},"pull_request":{"url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442","id":31387651,"html_url":"https://github.com/DataDog/dd-agent/pull/1442","diff_url":"https://github.com/DataDog/dd-agent/pull/1442.diff","patch_url":"https://github.com/DataDog/dd-agent/pull/1442.patch","issue_url":"https://api.github.com/repos/DataDog/dd-agent/issues/1442","number":1442,"state":"open","locked":false,"title":"[Jenkins] supporting the new folder naming convention","user":{"login":"hkaj","id":5287287,"avatar_url":"https://avatars.githubusercontent.com/u/5287287?v=3","gravatar_id":"","url":"https://api.github.com/users/hkaj","html_url":"https://github.com/hkaj","followers_url":"https://api.github.com/users/hkaj/followers","following_url":"https://api.github.com/users/hkaj/following{/other_user}","gists_url":"https://api.github.com/users/hkaj/gists{/gist_id}","starred_url":"https://api.github.com/users/hkaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hkaj/subscriptions","organizations_url":"https://api.github.com/users/hkaj/orgs","repos_url":"https://api.github.com/users/hkaj/repos","events_url":"https://api.github.com/users/hkaj/events{/privacy}","received_events_url":"https://api.github.com/users/hkaj/received_events","type":"User","site_admin":false},"body":"Starting from v1.597, the build folder names are not named with a timestamp anymore but with an ID. We have to get the timestamp from the `build.xml` file and to use the folder name to guess the build number.","created_at":"2015-03-17T23:17:18Z","updated_at":"2015-03-18T15:18:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6c5f1052efd29e084f057c8a5175f9b5bc26e97a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442/commits","review_comments_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442/comments","review_comment_url":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/issues/1442/comments","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/ce5334d2369b04e19f4e2fc09691ac98cca4fb4b","head":{"label":"DataDog:haissam/jenkins-new-folder-format","ref":"haissam/jenkins-new-folder-format","sha":"ce5334d2369b04e19f4e2fc09691ac98cca4fb4b","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":1210071,"name":"dd-agent","full_name":"DataDog/dd-agent","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/dd-agent","description":"Datadog Agent","fork":false,"url":"https://api.github.com/repos/DataDog/dd-agent","forks_url":"https://api.github.com/repos/DataDog/dd-agent/forks","keys_url":"https://api.github.com/repos/DataDog/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/dd-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/dd-agent/events","assignees_url":"https://api.github.com/repos/DataDog/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/dd-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/dd-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/dd-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/dd-agent/merges","archive_url":"https://api.github.com/repos/DataDog/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/dd-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/dd-agent/releases{/id}","created_at":"2010-12-31T03:02:47Z","updated_at":"2015-03-17T22:27:29Z","pushed_at":"2015-03-18T14:51:27Z","git_url":"git://github.com/DataDog/dd-agent.git","ssh_url":"git@github.com:DataDog/dd-agent.git","clone_url":"https://github.com/DataDog/dd-agent.git","svn_url":"https://github.com/DataDog/dd-agent","homepage":"http://docs.datadoghq.com/","size":50955,"stargazers_count":259,"watchers_count":259,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":183,"mirror_url":null,"open_issues_count":158,"forks":183,"open_issues":158,"watchers":259,"default_branch":"master"}},"base":{"label":"DataDog:master","ref":"master","sha":"da7399f20f8b8ce3c392bd058ec46c96ad266e73","user":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"repo":{"id":1210071,"name":"dd-agent","full_name":"DataDog/dd-agent","owner":{"login":"DataDog","id":365230,"avatar_url":"https://avatars.githubusercontent.com/u/365230?v=3","gravatar_id":"","url":"https://api.github.com/users/DataDog","html_url":"https://github.com/DataDog","followers_url":"https://api.github.com/users/DataDog/followers","following_url":"https://api.github.com/users/DataDog/following{/other_user}","gists_url":"https://api.github.com/users/DataDog/gists{/gist_id}","starred_url":"https://api.github.com/users/DataDog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DataDog/subscriptions","organizations_url":"https://api.github.com/users/DataDog/orgs","repos_url":"https://api.github.com/users/DataDog/repos","events_url":"https://api.github.com/users/DataDog/events{/privacy}","received_events_url":"https://api.github.com/users/DataDog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DataDog/dd-agent","description":"Datadog Agent","fork":false,"url":"https://api.github.com/repos/DataDog/dd-agent","forks_url":"https://api.github.com/repos/DataDog/dd-agent/forks","keys_url":"https://api.github.com/repos/DataDog/dd-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DataDog/dd-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DataDog/dd-agent/teams","hooks_url":"https://api.github.com/repos/DataDog/dd-agent/hooks","issue_events_url":"https://api.github.com/repos/DataDog/dd-agent/issues/events{/number}","events_url":"https://api.github.com/repos/DataDog/dd-agent/events","assignees_url":"https://api.github.com/repos/DataDog/dd-agent/assignees{/user}","branches_url":"https://api.github.com/repos/DataDog/dd-agent/branches{/branch}","tags_url":"https://api.github.com/repos/DataDog/dd-agent/tags","blobs_url":"https://api.github.com/repos/DataDog/dd-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DataDog/dd-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DataDog/dd-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/DataDog/dd-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DataDog/dd-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/DataDog/dd-agent/languages","stargazers_url":"https://api.github.com/repos/DataDog/dd-agent/stargazers","contributors_url":"https://api.github.com/repos/DataDog/dd-agent/contributors","subscribers_url":"https://api.github.com/repos/DataDog/dd-agent/subscribers","subscription_url":"https://api.github.com/repos/DataDog/dd-agent/subscription","commits_url":"https://api.github.com/repos/DataDog/dd-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/DataDog/dd-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/DataDog/dd-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/DataDog/dd-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/DataDog/dd-agent/contents/{+path}","compare_url":"https://api.github.com/repos/DataDog/dd-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DataDog/dd-agent/merges","archive_url":"https://api.github.com/repos/DataDog/dd-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DataDog/dd-agent/downloads","issues_url":"https://api.github.com/repos/DataDog/dd-agent/issues{/number}","pulls_url":"https://api.github.com/repos/DataDog/dd-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/DataDog/dd-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/DataDog/dd-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DataDog/dd-agent/labels{/name}","releases_url":"https://api.github.com/repos/DataDog/dd-agent/releases{/id}","created_at":"2010-12-31T03:02:47Z","updated_at":"2015-03-17T22:27:29Z","pushed_at":"2015-03-18T14:51:27Z","git_url":"git://github.com/DataDog/dd-agent.git","ssh_url":"git@github.com:DataDog/dd-agent.git","clone_url":"https://github.com/DataDog/dd-agent.git","svn_url":"https://github.com/DataDog/dd-agent","homepage":"http://docs.datadoghq.com/","size":50955,"stargazers_count":259,"watchers_count":259,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":183,"mirror_url":null,"open_issues_count":158,"forks":183,"open_issues":158,"watchers":259,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442"},"html":{"href":"https://github.com/DataDog/dd-agent/pull/1442"},"issue":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1442"},"comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/issues/1442/comments"},"review_comments":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442/comments"},"review_comment":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DataDog/dd-agent/pulls/1442/commits"},"statuses":{"href":"https://api.github.com/repos/DataDog/dd-agent/statuses/ce5334d2369b04e19f4e2fc09691ac98cca4fb4b"}}}}