上接遇到的奇怪需求和其他问题。。。。。


7、优化预警提醒

需求:其实需求也是蛮简单的需要告警信息更加及时可靠,之前的折中方案是,将console output log全部通过邮件推送到我个人邮箱,但是还是显得不及时,因为邮件浏览非常不及时,现在我们的交流工具主要是slack,故而集成到slack即好。
解决方案:借助requests auth获取jenkins console output log,借助slack web api推送到个人或者channel,借助jenkins插件Execute a set of scripts在job执行出错时候,预警。
看脚本:

1
2
3
4
5
6
7
8
9
10
11
#获取jenkins output log
def get_content(job_url):
"""取出console log全部内容"""
url = job_url + "consoleText/api/json"
headers = {
"Content-Type": "application/json",
"Accept": "application/json"
}
response = requests.get(url, auth=("xxxx", "xxxxx"))
assert response.status_code == requests.codes.ok
return response.content

1
2
3
4
#借助slack推送个人或者channel
slack web api地址:https://api.slack.com/methods/chat.postMessage
slack = Slacker(api_token, 100)
slack.chat.post_message(userid, text=text, attachments=data)
1
添加execute a set of scripts并且勾选Execute script only if builds fails

8、同时存在xcode7和xcode8的时候有报错

报错为:

1
2
3
4
CoreSimulator is attempting to unload a stale CoreSimulatorService job. Detected Xcode.app relocation or CoreSimulatorService version change. Framework path (/
Applications/Xcode.app/Contents/Developer/Library/PrivateFrameworks/CoreSimulator.framework) and version (303.8) does not match existing job path (/Applications
/Xcode7.app/Contents/Developer/Library/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc) and version
(209.19).

解决:

1
launchctl remove com.apple.CoreSimulator.CoreSimulatorService || true

9、一直选择不到scheme

现象就是一直报错的提示是选择不到scheme
解决:

1
2
3
4
5
Choose Scheme > Manage Schemes (from the Product Menu).
Ensure the 'Shared' box is checked for that scheme
A new .xcscheme file has been created in your project at
WorkspaceName.xcworkspace/xcshareddata/xcschemes.
Commit this file to your repository

10、解决了bash: shell_session_update: command not found

解决方法很简单rvm get head
真想说脏话。。。。。。