Skip to content

Instantly share code, notes, and snippets.

@camd
Created March 25, 2016 19:52
Show Gist options
  • Save camd/d53bfbd5c745e8e7412a to your computer and use it in GitHub Desktop.
Save camd/d53bfbd5c745e8e7412a to your computer and use it in GitHub Desktop.
import json
from thclient import (TreeherderClient,
TreeherderJobCollection)
job = {
"job_guid": "1a1f13c7-f14d-48c6-8d6b-cb08501ef42c/1",
"build_system_type": "taskcluster",
"build_platform": {
"platform": "b2g-emu-jb",
"os_name": "-",
"architecture": "-"
},
"machine_platform": {
"platform": "b2g-emu-jb",
"os_name": "-",
"architecture": "-"
},
"name": "[TC] B2G JB Emulator: (Opt)",
"reason": "scheduled",
"job_symbol": "B",
"submit_timestamp": 1455722483,
"who": "mozilla-taskcluster-maintenance@mozilla.com",
"option_collection": {
"opt": True
},
"group_name": "Submitted by taskcluster",
"group_symbol": "?",
"tier": 1,
"artifacts": [
{
"type": "json",
"name": "text_log_summary",
"blob": {
"step_data": {
"all_errors": [
"[taskcluster:error] Unable to retrigger task. Error: testing - this shouldn't happen."
],
"steps": []
},
"logname": "error_log",
"parse_status": "parsed"
}
},
{
"type": "json",
"name": "Bug suggestions",
"blob": [
{
"search": "[taskcluster:error] Unable to retrigger task. Error: testing - this shouldn't happen.",
"search_terms": [],
"bugs": {
"open_recent": [],
"all_others": []
}
}
]
}
],
"result": "exception",
"state": "completed"
}
job_guid = "3a9bb7c0-53bc-4574-bad9-640193a97f61"
artifacts2 = [
{
"type": "json",
"name": "text_log_summary",
"job_guid": job_guid,
"blob": json.dumps({
"step_data": {
"all_errors": [
"[taskcluster:error] Unable to retrigger task. Error: testing - this shouldn't happen."
],
"steps": []
},
"logname": "error_log",
"parse_status": "parsed"
})
},
{
"type": "json",
"name": "Bug suggestions",
"job_guid": job_guid,
"blob": [
{
"search": "[taskcluster:error] Unable to retrigger task. Error: testing - this shouldn't happen.",
"search_terms": [],
"bugs": {
"open_recent": [],
"all_others": []
}
}
]
}
]
artifacts = []
job2 = {
"job_guid": job_guid,
"build_system_type": "taskcluster",
"build_platform": {
"platform": "b2g-emu-kk",
"os_name": "-",
"architecture": "-"
},
"machine_platform": {
"platform": "b2g-emu-kk",
"os_name": "-",
"architecture": "-"
},
"machine": "unknown",
"name": "[TC] B2G KK Emulator (Opt)",
"reason": "scheduled",
"job_symbol": "CAM",
"submit_timestamp": 1455831566,
"who": "mozilla-taskcluster-maintenance@mozilla.com",
"option_collection": {
"opt": True
},
"group_name": "Submitted by taskcluster",
"group_symbol": "?",
"tier": 2,
"artifacts": artifacts,
"result": "exception",
"state": "completed"
}
job_data = {
# 'revision_hash': "e6efc82701a90b3282ed78ede946f25e6cc6eb3e",
'revision': "272ec90eff71",
'project': "mozilla-inbound",
'job': job2
}
tjc = TreeherderJobCollection()
tjc.add(tjc.get_job(job_data))
# created with: ./manage.py create_credentials cam-hawk treeherder@mozilla.com "Description"
client = TreeherderClient(protocol='http',
host='local.treeherder.mozilla.org',
client_id='cam-hawk',
secret='<put your secret from above command here>'
)
client.post_collection('mozilla-inbound', tjc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment