diff --git a/source/_posts/linux/gitlab调用jenkins实现自动构建.md b/source/_posts/linux/gitlab调用jenkins实现自动构建.md new file mode 100644 index 0000000..9cc5abe --- /dev/null +++ b/source/_posts/linux/gitlab调用jenkins实现自动构建.md @@ -0,0 +1,66 @@ +--- +title: gitlab调用jenkins实现自动构建 +date: 2019-03-31 13:01:42 +tags: + - linux + - jenkins +categories: + - linux +--- +gitlab本身支持**webhook**功能, 也就是在代码托管的一些生命周期内 +在指定阶段执行若干回调 +利用这一点, 我们就可以在push操作的时候, 直接触发jenkins任务构建 +从而实现自动化构建 + + +操作步骤 +### 1.安装插件 +首先需要在jenkins里面安装`GitLab Plugin` +![GitLab插件](/images/linux/jenkins/gitlab插件.png) +简介里面也有说明, 这个插件允许GitLab去触发jenkins构建 + +### 2.生成API Token +登陆gitlab, 进入个人设置, 生成Access Token +![Access Token](/images/linux/jenkins/API_Token.png) +生成之后记下这个token +(这个token只在这里显示一次, 之后无法查到) + +### 3.添加凭据 +回到jenkins当中, 添加凭据 +![添加凭据](/images/linux/jenkins/添加凭据.png) +类型选择`GitLab API token` ( 如果第1步中的插件正确安装就会有这一项, 如果没有可以检查一下插件情况 ) +API token粘贴从第2步中获得的token +ID可以不写, 描述自定 + +### 4.系统设置 +之后进入系统设置, 配置gitlab连接 +![gitlab连接设置](/images/linux/jenkins/gitlab连接设置.png) +这里的gitlab地址我使用的是官方的地址, 如果是自己搭建的gitlab环境, 写自己的地址即可 +下面的凭据就选第3步当中添加的 + +之后可以执行一下 Test Connection, 显示SUCCESS则表示token无误, 可以使用 + +### 5.配置任务 +对要进行触发构建的任务进行配置 +在**构建触发器**一栏勾选`Build when a change is pushed to GitLab` +详细勾选项如下, 大部分都是默认的 +![构建触发器](/images/linux/jenkins/构建触发器.png) +这里可以拿到一个`webhook URL`, 记下来 +下方可以点击Generate生成一个`Secret token`, 记下来 + +Allowed branches可以设定哪个分支的代码推送可以触发构建, 也可以是所有分支都触发 + +### 6.设置webhook +回到gitlab, 设置仓库级的webhook +进入到需要触发构建的仓库 +![设置webhook](/images/linux/jenkins/设置webhook.png) +这里的URL和Secret Token, 分别填入在第5步当中获得的`webhook URL`和`Secret token` +下面默认勾选的是push event, 也就是在推送提交到仓库的时候触发, 正好符合我们的需求 + +下面有Enable SSL verification, 如果jenkins所在的地址添加了合法的ssl可以勾选这项, 否则就不必勾选 +之后`Add webhook`即可 + +### 7.验证 +至此已经配置完成, 我们可以尝试提交代码到第6步中设置的仓库里 +之后到jenkins里面, 可以看到该任务已经自动触发了构建 +![验证](/images/linux/jenkins/验证.png) \ No newline at end of file diff --git a/source/_posts/linux/vim学习手记(2).md b/source/_posts/linux/vim学习手记(2).md index 64ab8a8..b78f73d 100644 --- a/source/_posts/linux/vim学习手记(2).md +++ b/source/_posts/linux/vim学习手记(2).md @@ -9,11 +9,11 @@ categories: --- ## 修改 查找 替换 - + ### 大小写的转换 + `~` - 转换当前光标所在的字符( 如果是小写就转为大写, 反之转为小写, 下同 ) + `g~w` - 当前光标之后的一个单词转换大小写 - + 这里同样是 操作+动作 的组合方式 比如`g~$`就是对当前位置到行尾进行大小写转换 @@ -63,3 +63,90 @@ flags是替换方式的标识 在vim当中要写作`\d\+` 除了[]不需要, `\d\+`同样可以写作`[0-9]\+` +## 缓冲区 +缓冲区是vim进行多文件编辑的一个基础功能 + +所有的文本编辑器在对文件进行编辑的时候, 都是先把文件的内容读到内存当中 +只有在进行修改后保存时才写入到磁盘 +缓冲区中的就是此时读取到内存的文件 + +我们可以使用vim命令同时打开多个文件 +比如`vim buf-*.txt`或者是`vim buf-1.txt buf-2.txt buf-3.txt` + +此时主界面显示出的是其中的第一个文件 +执行`:ls`或者`:buffers`或者`:files`可以查看缓冲区当中的文件 +![缓冲区](/images/linux/buffers.png) + +其中的 **%a** 是缓冲区的标记 +有以下几种 ++ `a` - 激活的 ( active ) ++ `h` - 隐藏的 ( hidden ) ++ `%` - 当前 ++ `#` - 交换 ++ `=` - 只读 ++ `+` - 已经更改的 ++ `-` - 不可更改的 + +其中交换代表的意思就是当前缓冲区的上一个 +比如从第二个切换到了第三个, 那么当前的是第三个, 交换是第二个 + +### 缓冲区切换 + ++ `:bp` - 上一个 ( buffer previous ) ++ `:bn` - 上一个 ( buffer next ) ++ `:bf` - 第一个 ( buffer first ) ++ `:bl` - 最后一个 ( buffer last ) ++ `:b {序号}/{文件名}` - 切换到指定缓冲区 ++ `:ball` - 同时激活所有缓冲区 ++ `:b#` - 切换到交换缓冲区 + +### 缓冲区列表操作 + +添加文件到缓冲区 ( buffer add ) +`:badd {文件名}` +( 这个文件不是必须存在, 不存在的话相当于创建新文件 ) + +删除缓冲区中的文件 ( buffer delete ) +`:bd {序号}/{文件名}` + ++ `:qall` - 退出全部缓冲区 ++ `:wall` - 写入全部缓冲区 ++ `:bufdo {命令}` - 对所有缓冲区执行该命令, 比如 **:bufdo set number** +( 所以退出全部缓冲区也可以写`:bufdo q` ) + +## 分屏 +只有缓冲区的操作, 毕竟一次只能看到一个文件 +vim还提供了分屏的支持 +使用参数`-O/o` ,分别代表竖直分屏和水平分屏 +``` +vim -O buf-1.txt buf-2.txt +``` +![竖直分屏](/images/linux/竖直分屏.png) + +### 添加分屏 + ++ `:sp` - 添加水平分屏 ++ `:vsp` - 添加竖直分屏 +![添加分屏](/images/linux/添加分屏.png) + +此时分屏出来的窗口当中打开的还是同一个缓冲区 +之后可以通过**缓冲区切换**来打开不同的缓冲区 + +### 焦点切换 +`ctrl+w h` 跳转到左边的窗口 +`ctrl+w j` 跳转到下面的窗口 +`ctrl+w k` 跳转到上面的窗口 +`ctrl+w l` 跳转到右边的窗口 + +`ctrl+w t` 跳转到最顶上的窗口 +`ctrl+w b` 跳转到最底下的窗口 + +### 调整大小 + +高度调整 +`ctrl+w {数字}+` 增大当前窗口的高度(行数), 默认是1 +`ctrl+w {数字}-` 减小当前窗口的高度(行数), 默认是1 + +宽度调整 +`ctrl+w {数字}>` 增大当前窗口的宽度(列数), 默认是1 +`ctrl+w {数字}<` 减小当前窗口的宽度(列数), 默认是1 \ No newline at end of file diff --git a/source/images/linux/buffers.png b/source/images/linux/buffers.png new file mode 100644 index 0000000..3fb93e7 Binary files /dev/null and b/source/images/linux/buffers.png differ diff --git a/source/images/linux/jenkins/API_Token.png b/source/images/linux/jenkins/API_Token.png new file mode 100644 index 0000000..72c9268 Binary files /dev/null and b/source/images/linux/jenkins/API_Token.png differ diff --git a/source/images/linux/jenkins/gitlab插件.png b/source/images/linux/jenkins/gitlab插件.png new file mode 100644 index 0000000..d362682 Binary files /dev/null and b/source/images/linux/jenkins/gitlab插件.png differ diff --git a/source/images/linux/jenkins/gitlab连接设置.png b/source/images/linux/jenkins/gitlab连接设置.png new file mode 100644 index 0000000..597a0c3 Binary files /dev/null and b/source/images/linux/jenkins/gitlab连接设置.png differ diff --git a/source/images/linux/jenkins/构建触发器.png b/source/images/linux/jenkins/构建触发器.png new file mode 100644 index 0000000..525f35e Binary files /dev/null and b/source/images/linux/jenkins/构建触发器.png differ diff --git a/source/images/linux/jenkins/添加凭据.png b/source/images/linux/jenkins/添加凭据.png new file mode 100644 index 0000000..179ef24 Binary files /dev/null and b/source/images/linux/jenkins/添加凭据.png differ diff --git a/source/images/linux/jenkins/设置webhook.png b/source/images/linux/jenkins/设置webhook.png new file mode 100644 index 0000000..c17ffa5 Binary files /dev/null and b/source/images/linux/jenkins/设置webhook.png differ diff --git a/source/images/linux/jenkins/验证.png b/source/images/linux/jenkins/验证.png new file mode 100644 index 0000000..2fec1a4 Binary files /dev/null and b/source/images/linux/jenkins/验证.png differ diff --git a/source/images/linux/添加分屏.png b/source/images/linux/添加分屏.png new file mode 100644 index 0000000..7d5b85a Binary files /dev/null and b/source/images/linux/添加分屏.png differ diff --git a/source/images/linux/竖直分屏.png b/source/images/linux/竖直分屏.png new file mode 100644 index 0000000..2931499 Binary files /dev/null and b/source/images/linux/竖直分屏.png differ