jenkins基本使用

创建证书步骤

证书存放目录

1
2
3
cd /home/gitsource/
mkdir <item_name>
cd <item_name>

创建全局存储证书

1
git config --global credential.helper store

获取版本(账号|密码)

1
git clone <Gitlab_url>

获取tag列表

1
git ls-remote -h -t <Gitlab_url> refs/tags/*

Jenkins配置

添加动态选择变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 创建变量参数
Dynamic Choice Parameter

Name
=>select_tag

Choices

=>
proc1 = ['/bin/bash', '-c', "git ls-remote -h -t http://git.epailive.com/epailive/phpweb.git refs/tags/v* "].execute()
proc2 = ['/bin/bash', '-c', "awk '{print \$2}'"].execute()
proc3 = ['/bin/bash', '-c', "sed s%^refs/heads%origin%"].execute()
proc4 = ['/bin/bash', '-c', "sort -nr"].execute()
proc5 = ['/bin/bash', '-c', "grep -v {}"].execute()

all = proc1 | proc2 | proc3 | proc4 |proc5
String result = all.text
result.tokenize()

=> 更改后,获取的字符串确实不用sed替换
proc1 = ['/bin/bash', '-c', "git ls-remote -h -t http://git.epailive.com/epailive/phpweb.git refs/tags/v* "].execute()
proc2 = ['/bin/bash', '-c', "awk '{print \$2}'"].execute()
proc3 = ['/bin/bash', '-c', "sort -nr"].execute()
proc4 = ['/bin/bash', '-c', "grep -v {}"].execute()

all = proc1 | proc2 | proc3 | proc4
String result = all.text
result.tokenize()

修改gitlab拉取规则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 资源管理
Git

# Repository URL
<gitlab url>

# Credentials
账号密码

# Branch Specifier (blank for 'any')
${select_tag}

# Additional Behaviours
## check out to a sub-directory
${BUILD_TAG} //内置变量