CI使用文档

CI使用文档

Git使用

1. Git pull远程与本地文件冲突

具体方法如下

git pull origin V250_CS  # 出现错误
git stash                # 缓存起来
git pull origin          # 分支
git stash pop            # 还原
git stash clear

2. git部署全局hooks

init.templatedir

Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY"section of git-init(1).)

mkdir -p ~/.git_template/hooks
cp commit-msg ~/.git_template/hooks
git config --global init.templatedir ~/.git_template

3. git提交模板

commit.template

Specify a file to use as the template for new commit messages. “~/” is expanded to the value of $HOME and “~user/” to the specified user’s home directory.

git config --global commit.template ~/.gitmsg

4. git设置默认编辑器

git 默认编辑器为nano

if [ -e "/usr/bin/vim" ]; then
    git config --global core.editor vim
else
    git config --global core.editor vi
fi

5. url替换

url.<base>.insteadOf

Any URL that starts with this value will be rewritten to start, instead, with <base>. In cases where some site serves a large number of repositories, and serves them with multiple access methods, and some users need to use different access methods, this feature allows people to specify any of the equivalent URLs and have git automatically rewrite the URL to the best alternative for the particular user, even for a never-before-seen repository on the site. When more than one insteadOf strings match a given URL, the longest match is used.

6.查看文件修改历史

  1. git log filename
    可以看到fileName相关的commit记录
  2. git log -p filename
    可以显示每次提交的diff
  3. 只看某次提交中的某个文件变化,可以直接加上fileName
    git show c5e69804bbd9725b5dece57f8cbece4a96b9f80b filename
  4. 文件追溯 (git blame),用于查看文件内容的引入
    git blame filename,
    如果只想查看某几行的代码的代码git blame -L m,n filename,
    • e.g : git blame -L 5,+4 t.cpp or git blame -L 2,13 t.cpp

7. gitignore配置

ignore文件在最初时配置,不要在git push后设置

配置语法:
1、配置语法:

  • 以斜杠“/”开头表示目录;
  • 以星号“*”通配多个字符;
  • 以问号“?”通配单个字符
  • 以方括号“[]”包含单个字符的匹配列表;
  • 以叹号“!”表示不忽略(跟踪)匹配到的文件或目录;
  • 此外,git 对于 .ignore 配置文件是按行从上到下进行规则匹配的,意味着如果前面的规则匹配的范围更大,则后面的规则将不会生效;

cpipe工程ignore配置

*.o
*.d
*.d.[0123456789]*
*.swp
*.bin
*.suo
*.obj
*.tlog
*.log
*.lastbuildstate
*.unsuccessfulbuild
*.sdf
*.opensdf
*.exe
*.ilk
*.pdb
*.pnm
*.yuv
*.m
*.user
*.db
*.ipch
*.iobj
*.ipdb
*.exp
*.tmp
*.opendb
*.raw

# Build results
[Dd]ebug/
[Rr]elease/

# Visual Studio 2015/2017 cache/options directory
.vs/
*.gcno

8. 出现 * (no branch)的处理

如果当前正工作在(no branch)上:
git checkout -b <working branch>,就会把(no branch)上的东西checkout到<working branch>分支

如果不小心从(no branch)branch切换到其他分支了,用 git log 不能查找到(no branch)的信息,不要担心,先用 git reflog 查到(no branch)的commit,然后:
git checkout -b backup commit

Gerrit使用

配置环境

  1. 安装Git。
  2. 安装TortoiseGit。
  3. 打开Git Bash,运行 curl -O http://10.69.192.132:8080/static/init-cpipe-env-new.sh && chmod +x init-cpipe-env-new.sh && bash init-cpipe-env-new.sh <your domain user name>

所有安装按照提示运行即可。

添加工程

  1. 登录Gerrit,打开Gerrit Project页面。可以看到页面上显示的是当前正在使用的所有Project。
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-tueYvRbN-1578301151548)(assets/Gerrit-Project.jpg)]

  2. 选中Create New Project来创建一个新的工程。

    • Project Name中填入你想创建的工程名称
    • RIghts Inherit From中选中All-Projects作为权限控制的继承。
    • 选中Create initial empty commit复选框。
    • 点击Create Project工程就创建完成了。
  3. 工程创建完成后,默认只有master分支,并且没有任何代码。

添加分支

  1. 登录Gerrit,打开Gerrit Project页面。在所有工程中选择你想要添加分支的工程。就会进入分支显示页面。
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-74XdpRfz-1578301151549)(assets/Gerrit-Branch.jpg)]
  2. Branch Name中填入想要添加的新分支名,在Initial Reviesion中填入分支的代码基础版本。(这个基础版本可以是分支名或者是某一次提交的commit-id名)
  3. 分支创建完成之后需要配置权限。选中Access就能进入分支的权限配置页面。
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WWayF5aB-1578301151549)(assets/Gerrit-Access.jpg)]
  4. 分支创建后有两个权限需要配置。一个是refs/for/*,一个是refs/heads/*
    • refs/for/*是用来进行代码提交的,只需要进行Push权限的配置。
    • refs/heads/*是代码实际存在的分支,需要进行Read权限配置,来控制谁能够下载代码。
      还需要进行Label Code-Review权限配置,来控制谁能对代码进行+1 +2操作。Submit权限配置,控制谁能够把代码合入。
    • 所有的权限配置既可以使用通配符*来控制所有分支,也可以通过写具体分支名来控制具体的分支。控制方式视策略而定。
    • 因为所有工程的权限配置都是继承自All-Projects,所有在All-Projects配置的权限都会在所有工程中生效。(Label Verified的权限就是在All-Projects中配置的。)
  5. 如果需要对新添加的分支添加跑图用例。请跳转到添加跑图用例
  6. 如果需要对新添加的分支添加自动合入到SVN功能。请跳转到添加SVN同步工程

Jenkins使用

哈哈

添加跑图用例

  1. 找到Jenkins服务器上的userContent\RemoteBatch\文件夹。打开Gerrit_Trigger.json文件,在resultKey下添加你想要的添加用例的分支。
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jW0TtfSX-1578301151550)(assets/Jenkins-GerritTrigger.jpg)]

    • 1.代表Gerrit Project
    • 2.代表Gerrit Branch
    • 3.代表该分支对应的跑图配置。
  2. userContent\RemoteBatch\result\文件夹在添加对应名称的配置文件。配置文件的配置方法和离线的跑图脚本一致。唯一不一致的地方为多了一个bat_parameter
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3TKf1vm3-1578301151550)(assets/Jenkins-batParameters.jpg)]

    • CPIPE_FOLDER 表示包含有makefile文件的文件夹名。每个Project的名称都不一样。
    • VS_PROJ 表示包含有cpipe_fwk_vc.sln文件的文件夹名。每个VS版本的文件夹名不一致。
    • BYPASS_BUILD 表示是否bypass各种build方式。
      cygwinvsvs_debugvs_x64vs_x64_debugbypass_build
      100001
      010002
      001004
      000108
      0000116
    • SQL_TABLE 为保留参数。不要改动。
    • enable_codecheck 表示是否打开各种静态检查。默认1(使用cppcheck检查)。
    • IMG_FOLDER 表示当前配置文件的所有验证图片从哪里取。该参数是相对于userContent\testimages\的相对路径。
  3. 在第二步配置的IMG_FOLDER目录下配置好测试图片。

添加SVN同步工程

  1. 打开Jenkins网页,选择新建Item来新建一个SVN同步工程。
  2. 输入任务名称,选择复制一个已经存在的SVN同步任务。
  3. 在参数列表中修改 CPIPE_FOLDER SVN_PATH SVN_USERNAME SVN_PASSWORD 的参数为新分支所使用的名称。
  4. 修改源码管理中的Repository URL为新分支的下载代码。
  5. 修改Gerrit Trigger中的想要触发的Project名和Branch名。
  6. 修改构建后操作中的邮件地址。
  7. 保存后,一个新的SVN同步工程就构建完成。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值