一,Jenkins用户权限
可以利用Role-based Authorization Strategy 插件来管理Jenkins用户权限



1,创建用户

2,创建权限组


3,分配角色

4,创建项目


5,登录egon用户查看

6,支持正则




二,凭证管理
要在Jenkins使用凭证管理功能,需要安装Credentials Binding插件。
系统管理--->

方式一:账号和密码






# 查看jenkins服务器上已经拉取了gitlab的代码
[root@\ jenkins~]# cd /var/lib/jenkins/workspace/shanghai_boy
[root@\ jenkins/var/lib/jenkins/workspace/shanghai_boy]# ll
total 8
-rw-r--r--. 1 jenkins jenkins 4 Apr 15 14:11 a.txt
-rw-r--r--. 1 jenkins jenkins 12 Apr 15 14:11 README.md
方式二:
SSH Username with private key:即使用私钥的SSH 用户名。这是一个SSH 秘钥对。公钥配置在GitHub上面,这里添加私钥。




方式三


# 公钥发送到指定服务器上
[root@\ jenkins~]# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.15.108
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub"
The authenticity of host '192.168.15.108 (192.168.15.108)' can't be established.
ECDSA key fingerprint is SHA256:PEnseRsQ3H01Fz7upthyVuJfTYF/AKSpERCAxx1052M.
ECDSA key fingerprint is MD5:e7:ba:23:9f:6c:2b:77:12:7b:68:a8:5f:bc:eb:c0:01.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.15.108's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.15.108'"
and check to make sure that only the key(s) you wanted were added.
#测试登录到web02
[root@\ jenkins~]# ssh 'root@192.168.15.108'
Last login: Thu Apr 15 08:46:34 2021 from 192.168.15.1
[root@\ web02~]# exit
logout
Connection to 192.168.15.108 closed.
第三种方式,可以不断的增加server信息,直接构建部署到该服务器上
三,简单构建流程:


验证:
[root@\ web02~]# cd /usr/share/nginx/html/
[root@\ web02/usr/share/nginx/html]# ll
total 0
drwxr-xr-x. 2 root root 67 Apr 15 17:38 bbb
[root@\ web02/usr/share/nginx/html]# cd bbb/
# 远程仓库内容
[root@\ web02/usr/share/nginx/html/bbb]# ll
total 16
-rw-r--r--. 1 root root 4 Apr 15 17:38 a.txt
-rw-r--r--. 1 root root 47 Apr 15 17:38 egon.txt
-rw-r--r--. 1 root root 12 Apr 15 17:38 README.md
-rw-r--r--. 1 root root 47 Apr 15 17:38 tet.txt
# 构建时执行的shell变量
[root@\ web02/usr/share/nginx/html/bbb]# cat egon.txt
http://192.168.15.90:8080/job/shanghai_boy/11/
[root@\ web02/usr/share/nginx/html/bbb]# cd
# 创建的目录
[root@\ web02~]# ll /egon/
total 0


网友评论