Search -

? jenkins ?    2019-01-11 16:19:24    2780    0    0
? jenkins ?    2019-01-11 16:19:24    5005    0    0

参数化触发器

Parameterized Trigger plugin

https://wiki.jenkins.io/display/JENKINS/Parameterized+Trigger+Plugin

? svn ? ? shell ?    2019-01-11 16:17:34    5059    1    0

Linux 端的svn 定时自动提交

 如果一个提交操作是定向定时的重复动作,我们可以把commit 的操作和参数对象抽象出来,封装在脚本中执行。并将脚本配置在crontab 中定时执行。


 

commit 操作解析

1. 当前workcopy 里各文件的状态 : svn stat


 

2. 当前状态分析:

?     Tests/dxj/case 1.1.1.test

!     Tests/dxj/modify sgw

M     Tests/dxj/modify sgw

? 表示新增文件,需要用svn add file 加入版本控制标识,才能使用commit 默认提交 。

!表示本地已删除的受控文件,需要用svn delete file 加入版本控制标识,才能使用commit 默认提交 。

M表示本地与上次更新的文件比较有修改,会默认在commit 的时候提交


 

3. 分离不同状态的文件并获取列表:

     svn st | grep "? \+" | sed "s/? \+//" > $Add_File

     "? \+" 表示匹配"?问号及其后的连续空格"。正则式 + 用转义符 \+ 表示多次匹配前一个字符,前一个字符是空格。

     sed "s/? \+//" :sed "s/A/B/"  表示用B 替换A 。 这里A="?问号及其后的连续空格" ,B=空, 即去掉前面一截,只保留文件列表 ,并写到$Add_File中


 

4. 把列表中的文件传给svn add 命令,加入版本控制:

     cat $Add_File | xargs svn add >>$LogFile

     为文件添加版本控制标识,命令为 svn add filename 。

     这里用管道|接收上一个命令cat 的结果,并用xargs 把前面的结果做为后一个命令的参数。


 

5. 带参数commit

     svn ci -m 'auto commit by script' --username svnmgr --password xxx >>$LogFile

     ci 表示 commit 

     -m  后面用引号加上 massage 

     --username 用户名

     --password 密码


 

crontab 配置

> crontab -e  

进行编辑定时任务列表,加入一行

10 5

? svn ? ? shell ?    2019-01-11 16:17:34    764    0    0

一个集中式版本控制工具

--通过在WORKING COPY (本地工作副本)  里增删改的提交(COMMIT)来改变版本库的内容, 通过更新(UPDATE)到WORKING COPY来获取他人的提交。每一次提交新增一个全局版本号。每个版本号代表着当前版本库的一个全局版本。

--支持分支管理(BRANCH/MERGE/SWITCH), 基线管理(TAG), 版本回退(REVERT), 冲突解决(RESOLVE  CONFLICTS)过程记录(HISTORY)。

--支持钩子脚本 : 与许多版本库版本控制系统一样,SVN 也支持hook 脚本:即在特定事件触发之前或之前执行的特定操作 。比如在 commit 之前执行检测 message 命令 。在 commit 之后执行发送邮件命令。

版本库搭建

参考 http://subversion.apache.org/packages.html

各系统的安装命令略有差异,详见官网链接,以下以ubuntu上的安装进行搭建。

工具安装

$ apt-get install subversion
$ apt-get install libapache2-svn​

版本库创建

mkdir /var/svn/Auto_script
svnadmin create /var/svn/Auto_script​

 

目录结构

一个 SVN 版本库初始化之后,会有在目录下生成一些配置目录。

conf/:
authz hooks-env.tmpl passwd svnserve.conf

db/:
current fsfs.conf locks rep-cache.db revs txn-current txn-protorevs write-lock
format fs-type min-unpacked-rev revprops transactions txn-current-lock uuid

hooks/:
post-commit.tmpl post-revprop-change.tmpl pre-commit pre-lock.tmpl pre-unlock.tmpl
post-lock.tmpl post-unlock.tmpl pre-commit.tmpl pre-revprop-change.tmpl start-commit.tmpl

locks/:
db.lock

? svn ? ? shell ?    2019-01-11 16:17:34    670    1    0

svnadmin dump --help

用法 :svnadmin dump REPOS_PATH [-r LOWER[:UPPER] [--incremental]]

[-r LOWER[:UPPER] 指定备份一个区间的版本:-r 0:30

[--incremental]] 增量备份一个区间的版本:-r 31:32 --incremental ,加上这个选项,增量备份才能追加在之前的备份上。

? svn ? ? shell ?    2019-01-11 16:17:34    1173    1    0

 

hotcopy  Description

This subcommand makes a full hot backup of your repository, including all hooks, configuration files, and, of course, database files. If you pass the --clean-logs option, svnadminwill perform a hot copy of your repository, and then remove unused Berkeley DB logs from the original repository. You can run this command at any time and make a safe copy of the repository, regardless of whether other processes are using the repository.

svnadmin hotcopy --help

Make a hot copy of a repository.
If --incremental is passed, data which already exists at the destination
is not copied again. Incremental mode is implemented for FSFS repositories.

Valid options:
--clean-logs : remove redundant Berkeley DB log files
from source repository [Berkeley DB]
--incremental : dump or hotcopy incrementall // 增量

 http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.hotcopy.html


用法

svnadmin hotcopy <Depot_Path> <Backup_Path >  --clean-logs --incremental​​

示例

cd /var/svn/svn_dir 
#切到版本库上层目录
svnlook 
? svn ?    2019-01-11 16:17:34    515    0    0

svn 自带的merge 工具 可以更换为我们熟悉的Beyond-Compare 或其他比对工具


右击菜单 setting -> Diff Viewer -> Merge Tool -> External 填写本机compare 工具的安装路径

例如:C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

图片标题

 
2019-01-11 16:19:24    1035    0    0

整理中

 

jenkins 插件开发环境安装

https://jenkins.io/doc/developer/plugin-development/

 ......

12/12