日常1

1. jenkins pipeline中获取shell命令的标准输出或者状态

def result = sh returnStdout: true, script: "git rev-parse --short HEAD"
result = git-commit_suffix.trim()

$ git rev-parse --short HEAD 获取最新commit id或者说sha的简短结果
trim() 函数移除字符串两侧的空白字符或其他预定义字符
ref: https://www.cnblogs.com/chenyishi/p/10943352.html

2. Pylama: Code audit tool for Python and JavaScript.
ref: [https://pylama.readthedocs.io/en/latest/#requirements]

3. coverage.py是一个用来统计python程序代码覆盖率的工具。
无论是单元测试、API测试还是功能性测试,最终都是调用了产品的代码;如何评价这些测试的效率?这些测试是否真正全部或者大部分覆盖了产品的代码,这个时候,代码覆盖率(code coverage)就是一个比较有价值的参考指标了。
ref: https://www.jianshu.com/p/6fde7d573994
ref: [https://coverage.readthedocs.io/en/latest/cmd.html]

4. jenkins中的插件:
[https://www.jenkins.io/doc/pipeline/steps/]
SonarQube
readJSON : readJSON file: 'dir/input.json' or readJSON text: '{ "key": "value" }'
gitlab pulgin
SCM Step: checkout scm
input: Wait for interactive input input
Credentials Binding Plugin: withCredentials(){[usernamePassword()]}
Email Extension Plugin: emailext()
Pipeline: Multibranch -> properties: Set job properties
properties()
JIRA Pipeline Steps: jiraNewIssue issue: testIssue

5. Jenkins中的basic steps
[https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/]
timeout(){}
waitUntil{}
echo: Print Message
withEnv(['a=b']){} 设置环境变量
error: Error signal error "some string"
writeFile: Write file to workspace


**6. Groovy中的一些function**
Groovy ```toString()```方法
```return```
equals()方法: ```x.equals(y)```
```println```
异常捕捉机制```try{}catch(){}```
Groovy split()方法 ```some_string.split(',')```
size()方法,查看列表数量```list.size()```
replaceAll() 方法,替换捕捉的字符:
```stringa.replaceAll(String regex, String replacement)
```subString()``` 返回一个截取的新字符串

**7. Python内置模块-decimal:**

**8. python内置模块之typing**

**9. python内置模块 uuid**

**10.python内置模块之decimal**

**11. Python中```__all__```的用法**
```__all__``` 的作用就是定义公开接口
ref: [https://blog.csdn.net/hang916/article/details/79474821]
python模块中的```__all__```属性,可用于模块导入时限制,如:
from module import *
此时被导入模块若定义了```__all__```属性,则只有```__all__```内指定的属性、方法、类可被导入

**12. python第三方模块 - click**
click模块是Flask的作者开发的一个第三方模块,用于快速创建命令行
Click对argparse的主要改在在于易用性,使用click模块主要分为两个步骤:
使用```@click.command() ```装饰一个函数,使之成为命令行接口
使用```@click.option() ```等装饰函数,为其添加命令行选项

**13. python第三方库click_plugins**

**14. python第三方库logzero**

**15. Python包管理工具setuptools**
ref:[https://www.jianshu.com/p/9a54e9f3e059]

**16.  ConfigParser  python的配置文件.ini**
ref: [https://www.cnblogs.com/weizhideweilai/p/9515046.html](https://www.cnblogs.com/weizhideweilai/p/9515046.html)

**17. linux中的一些命令**
```uuidgen``` 生成一个新的uuid值

**18. python内置模块 getopt()**
```getopt.getopt(args, shortOpts, longOpts=[])```
ref: [https://docs.python.org/3.1/library/getopt.html#getopt.getopt]

**19. python的三方库gitlab**
需要创建```gitlab.Gitlab``` class
ref:[https://python-gitlab.readthedocs.io/en/stable/gl_objects/templates.html]

**20. python的三方库Jenkins**
提供Jenkins的python api
ref:[https://python-jenkins.readthedocs.io/en/latest/]

**21. Linux上的一些command**
```nc```命令:```nc -z -w 3 $destination $port```  //查看任意TCP和UDP连接和监听,这里指查看目标连接的端口,-w指timeout时间为3s,-z指nc应该扫描监听的进程,但是不给目标发送数据

```set -e``` 只要脚本发生错误就终止执行
```#!/bin/bash
    set -e

ref:[https://wenku.baidu.com/view/3517159305a1b0717fd5360cba1aa81145318f38.html]
在 /home 目录下的所有文件中查找包含 test 字符串的文件

grep -r -e "test" /home/
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。