博文

flask/post+jsonschema报错:None is not of type 'object'

用python的unittest,对flask的post测试,testcase如下: def test_post_new_testCheckingService ( self ): rsp = self .app.post( '/test' , data =json.dumps(json_new)).data data = json.loads(rsp) self .assertEquals( 1 , data[ 'return_code' ]) 但是报错: [jenkins_bot@A04-R08-I53-67 testChecking]$ python test_testCheckingService.py ...WARNING: input json is invalid: (None is not of type 'object' Failed validating 'type' in schema:     {'description': 'POST request coming in test service API',      'properties': {'note': {'description': 'The note for the operation',                              'type': 'string'},                            ...详细的jsonschema定义省略...      'title': ...

解决jira的catalina.out日志文件过大的问题

利用linux/unix系统一般都有的logrotate来解决: [root@A02-R12-I167-39-6X25S62 logs]# which logrotate /usr/sbin/logrotate [root@A02-R12-I167-39-6X25S62 logs]# echo > /export/atlassian/jira/logs/catalina.out [root@A02-R12-I167-39-6X25S62 logs]# vi /etc/logrotate.d/jira-tomcat.conf /export/atlassian/jira/logs/catalina.out {         rotate 5         size 20M         nocompress         notifempty         missingok         copytruncate         su jira jira } [root@A02-R12-I167-39-6X25S62 logs]# logrotate --force /etc/logrotate.d/jira-tomcat.conf [root@A02-R12-I167-39-6X25S62 logs]# ls -altr drwx------ 2 jira jira 12288 May 15 11:50 . rw-r---- 1 jira jira 4784 May 15 11:50 catalina.out rw-r---- 1 jira jira 69566 May 15 11:50 catalina.out.1

一个repo关联多个git

    其实挺简单的,网上说的改什么.git/config文件并不准确,还挺有误导性的。过程简单如下。怎么装git就不说了。     使用多个git账号的关键是需要让git的ssh认证能同时支持多个git。我们知道git认证是通过.ssh/id_rsa密钥来进行的。而如果同时用多个git,那么必然需要生成多个密钥对。所以生成密钥的时候,不能都用默认的密钥对的名字id_rsa,需要加以区分,比如加后缀名: # ssh-keygen -t rsa -C "your_email@youremail.com"     我们一般是一路回车按到底,但对于多个git,在屏幕回显生成密钥对文件名时,需要自定义一下,否则都用默认的id_rsa,那么后面的就会覆盖掉前面的 >Generating public/private rsa key pair. Enter file in which to save the key  (/Users/your_user_directory/.ssh/id_rsa):<press enter>     这里不要用默认的文件名,自定义一个新的文件名,比如输入 /Users/your_user_directory/.ssh/id_rsa _github     后面的可以一路回车按到底     同理,下一个git需要生成密钥对的时候,也在这里改一下默认文件名,比如 /Users/your_user_directory/.ssh/id_rsa _company     但是这样有个问题,回头做push/pull的时候,因为git默认是去找.ssh/id_rsa,所以找不到id_rsa会报认证失败。所以还必须让git知道哪个git应该用哪个密钥。还是在.ssh目录下,有个config文件,编辑此文件,有几个git就加几个section。注意是改./ssh下的config,不是像很多网上文章说的那样改.git下的config。config的例子: Host company   HostName git.company.com ...

利用Gitlab的Jira issue tracker实现Jira issue自动根据Gitlab commit/merge更新状态

图片
  首先一个参考文档: http://git.jd.com/help/user/project/integrations/jira   其次此文档中与我的jira版本和gitlab版本实际差异还是较大,记一下趟过的坑吧: 1. jira上的配置:   我用的是jira7.3.8,配置用户组权限处和上文不一样,设置group权限是从管理->系统->安全->全局权限进去设置,而且没有显示有jira-core的,于是将gitlab-developers设成了[JIRA 管理员]的权限 2. Gitlab上的配置:    1) Gitlab配置需有repo的master权限    2) 配置的时候从integration进去,是点击Jira转进link,而不是点前面的电源开关的符号,本废在这上面竟然被block了一下-_-b    3) JIRA API URL直接填与上面的Web URL一样就行    4) Transition ID这个解释起来比较复杂。首先,用上文的方法去取,我得到的是这样的输出: $  curl -s http://gitlab:gitlab@cloudjira.jd.com/rest/api/2/issue/TEST-3/transitions { "expand":"transitions", "transitions": [ {"id":"191", "name":"on-going", "to": {"self":"http://cloudjira.jd.com/rest/api/2/status/10301", "description":"", "iconUrl":"http://cloudjira.jd.com/images/icons/statuses/generic.png", "name":"Develope...

tar: Removing leading `/' from member names

或是中文:tar: 从成员名中删除开头的“/” 首先,这其实不是一个错误,虽然是输出到了stderr里,但其实是系统的一个提示,如所述,删掉了开头的/符号,亦即,去掉了绝对路径的意思 出现此条告警,是因为指定打包目录时,给的是绝对路径,比如: # tar zcvf name.tar.gz /home/test/test_folder tar处理时,默认是将/home/test/test_folder的开头的"/"删掉,变为home/test/test_folder这种格式,这样,稍后要untar的时候,不至于将untar出来的文件直接按绝对路径覆盖了原始的文件,在很多情况下,这并非我们的原意,我们会更倾向于只是把备份文件解到一个另外的文件目录下,查看对比。所以,tar的这种默认行为其实是更合理的 也所以说,网上很多文章对此告警给出的解决方法用p选项强制tar不要删除开头的"/",其实在大多数情况下,并不是一个好的解决方法 # tar zcvfp name.tar.gz /home/test/test_folder 虽然用p选项的确不报警了,但是如上所述,消除报警一时爽,将来解压的时候很可能会灾难的 tar自己的解决方法,就是将绝对路径改为相对路径,比如在当前目录下 # cd /home/test # tar zcvf name.tar.gz test_folder 另一种方法,可以使用-C中转一下,比如 # tar zcvf name.tar.gz -C / home/test/test_folder -C /的意思是说指定目录到根目录/,然后把后面的绝对路径开始的"/"去掉,这样,也能达到既使用绝对路径,又不会有报警的目的 但是shell编程的时候,经常会使用变量,比如 # target=/home/test/test_folder # tar zcvf name.tar.gz $target 这样的话,除非定义变量的时候规避"/",否则确实没有啥好办法防止报警。但如开头所述,这其实是一条info而非error,所以个人觉得,宁可报警,也不要用p选项的好

jira日志报警Establishing SSL connection without server's identity verification is not recommended

在/export/atlassian/jira/logs/catalina.out中,每5分钟就重复3条日志:  Thu Mar 01 13:54:54 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 如log所述,这是因为MySQL增加了安全性检查。要避免被flood,要么配成https访问,要么显性地声明禁用SSL 配SSL的方法Atlassian官网上有。不过因为手头没有CA证书,所以这里采用第2种解决方法,先避免被flood。 方法: 1. 到$JIRA_DATA目录下,我的是/export/atlassian/application-data/jira,修改dbconfig.xml文件。修改之前注意备份。这个文件一旦损坏,jira重启读不到这个文件,会重新初始化。 # vi dbconfig.xml 找到jdbc的部分,把url加个后缀,即上述log中要求的useSSL=false,如下述红色部分:   <jdbc-datasource>     <url>jdbc:mysql://localhost:3306/jira?useUn...

访问Jenkins API的几个小trick

1. 根据jenkins页面的url,加/api/xml或/api/json即可访问xml或json的输出 e.g. http://jenkinsHost/job/jobname/buildNum/plugin/api/json 2. 用pretty参数规整输出可读 e.g. http://jenkinsJob/api/json?pretty=true 3. 用depth参数指定要获取的层次 e.g. http://jenkinsJob/api/json?depth=2 4. 用&连接参数 e.g. http://jenkinsJob/api/json?depth=2&pretty=true 5. 但是用curl访问时,linux系统会将&解析为放在后台执行的命令,所以url需用引号括起来 e.g. curl 'http://jenkinsJob/api/json?depth=2&pretty=true' 6. 用tree指定要访问的node节点 e.g. http://jenkinsJob/api/json?tree=results[elements[*]] 7. 但是用curl访问时,方括号需用反斜线转义 e.g. curl -s 'http://jenkinsJob/api/json?pretty=true&tree=results\[elements\[*\]\]'