Q1. 修改密码提示错误 9 errors prohibited this user from being saved:
若是老是出现什么502说明内存不足,因为gitlab最低配置是2G内存。将虚拟机分配至2G以上后,点击没有问题。若是出现404页面刷新一下即可。
网上说有默认的账号和密码,然而却无法登录成功。这里需要设置下默认账号的密码
1、切换到相应路径下
cd /opt/GitLab/bin/
2、打开控制台
gitlab-rails console production
3、查询用户账号信息并赋值给u
u=User.where(id:1).first
4、设置该用户名的密码,密码这里不要使用引号,不然会无法登录成功
u.password=12345678
5、确认密码
u.password_confirmation=12345678
6、保存信息
u.save!
7、最后退出
exit
Q2: 推送内容到Gitlab时报错
remote: GitLab: You are not allowed to push code to protected branches on this project.
由于默认分支保护,需要调整保护策略
修改成:
Q3:Urlis blocked: Requests to the local network are not allowed
gitlab webhook错误
Q4:Error 403 anonymous is missing the Job/Build permission
jenkins gitlab
不支持匿名build, 这是回到jenkins中,在 系统管理 -> 全局安全管理中, 勾选 匿名用户具有可读权限
系统管理 -> 系统设置 -> 去掉 Enable authentication for ‘/project’ end-point
Q5:git clone https://huggingface.co/lmsys/vicuna-7b-v1.3
Cloning into 'vicuna-7b-v1.3'...
fatal: unable to access 'https://huggingface.co/lmsys/vicuna-7b-v1.3/': gnutls_handshake() failed: Error in the pull function.
#####apt-get source git
提示错误:E: You must put some 'deb-src' URIs in your sources.list
用命令修改资源列表文件:
sudo sed -i -- 's/#deb-src/deb-src/g' /etc/apt/sources.list ; sudo sed -i -- 's/# deb-src/deb-src/g' /etc/apt/sources.list
执行
sudo apt-get update
git config --global http.sslVerify "false"
sudo apt-get install git-lfs
git lfs clone http://huggingface.co/lmsys/vicuna-7b-v1.3
Q6:jenkins 链接gitlab 错误
Jenkins连接gitlab报错:returned status code 128
1.gitlab 里的账号密码,项目权限需要配置正确
2.jenkins 里的凭证,账号密码,需要跟gitlab里的一致
Q7:GitLab提交代码之后自动触发Jenkins构建
在gitlab中创建token
复制token,此token只显示一次:
Q8:大文件下载
export https_proxy=http://192.168.204.150:5888
export http_proxy=http://192.168.204.150:5888
git clone https://huggingface.co/lmsys/vicuna-7b-v1.3
git最新版本的可以,不是最新版本安装git lfs https://git-lfs.com/
Q9:删除项目
Q10:configFileProvider 公共配置项
https://github.com/jenkinsci/config-file-provider-plugin
configFileProvider([configFile(fileId: 'bwoil-maven-setting', variable: 'MAVEN_SETTINGS')]) { sh "mvn -s $MAVEN_SETTINGS clean package -pl ${env.BUILD_DIR} -DskipTests -Dmaven.compile.fork=true -am" }
Q11:gitlab 免密配置
gitlab 免密配置
检查:
cat ~/.SSH/id_rsa.pub
获取账号 ssh key
ssh-keygen -t rsa -C "admin@admin.com"
查看key
cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBItymoy2NpUul70O7fUB/BvbR6zXswtJouW3kfAWmitCu7eojHno6R3YntRPdpJZ2mak6ietJK yFZEmoSO/vjsOV297GT1Dj ibSB1uxX1PZbQGFUNTdRAQH3Y7axbgc53QDkN6EZ7XPS2lKAy9vI7kNnYgbN3C44CPzZGWpKPz0cW9QTnL9Bh6B5Iw95DSCaT077NRVOZyxyyr7YD9m9g47oysW19M5p6u4BYDUCwds8KeNhwjRQjOOqUdqNYzpE4b0hgFJPdfCNVMUor0ZYpcQ9Q5pW3vR106Pc7WOrZhen02HR3F8r9oFifzI ylQoF4naOlSSprN7JNw06c5 admin@admin.com
把key 信息添加到 gitlab 的SSH key 中
Q12:gitlab 开启ssh
1.本地生成ssh puBlic key 上传到gitlab
2.使用ssh协议上传
如仓库地址:git@gitlab.umi-meta.com:backend/cpp-world.git
3.指定ssh协议
git clone ssh://git@gitlab.umi-meta.com:30022/devops/helm-chart-repo.git
a.需要修改路径
b.需要确认ssh 端口(目标主机端口为 30022,docker启动)
gitlab_rails['gitlab_shell_ssh_port'] = 30022 标识(系统内仍为22端口)
#nginx
version: '3.8'
services:
nginx:
# image: nginx:1.22.1
build:
context: .
dockerfile: ./dockerfile
args:
buildno: 1
container_name: nginx
volumes:
- ./conf:/etc/nginx/conf.d
- ./logs:/var/log/nginx
- ./ssl:/etc/nginx/ssl
- ./nginx.conf:/etc/nginx/nginx.conf
- /data/gitlab/data:/var/opt/gitlab
- /etc/localtime:/etc/localtime:ro
ports:
- "80:80"
- "443:443"
networks:
- meta
networks:
meta:
external: true
name: meta
#gitlab
version: '3.6'
services:
gitlab:
# image: 'gitlab/gitlab-ce:15.10.2-ce.0'
image: 'gitlab/gitlab-ce:16.0.1-ce.0'
container_name: gitlab
restart: always
hostname: 'meta-gitlab'
environment:
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails['gitlab_shell_ssh_port'] = 30022
# external_url 'https://gitlab.xxx.com'
# external_url 'https://gitlab.xxx.com'
# Add any other gitlab.rb configuration here, each on its own line
ports:
# - '80:80'
# - '443:443'
- '30022:22'
volumes:
- '/data/gitlab/config:/etc/gitlab'
- '/data/gitlab/logs:/var/log/gitlab'
- '/data/gitlab/data:/var/opt/gitlab'
shm_size: '256m'
networks:
- meta
networks:
meta:
external: true
name: meta
Q13:gitlab 命令
GitLab常用命令
sudo gitlab-ctl start # 启动所有 gitlab 组件;
sudo gitlab-ctl stop # 停止所有 gitlab 组件;
sudo gitlab-ctl restart # 重启所有 gitlab 组件;
sudo gitlab-ctl status # 查看服务状态;
sudo gitlab-ctl reconfigure # 启动服务;
sudo vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
sudo gitlab-ctl tail # 查看日志;
命令方式提交
需要先生成SSH key 信息
Command line instructions
Git global setup
git config --global user.name "hk" git config --global user.email "admin@admin.com"
Q14:gitlab 与 jenkins拉通
配置专属账号
账号:jenkinsci
密码:meng2022
访问令牌:
jenkinsci
P3yK9xppauWJ47x9D2Hb
jenkins配置插件
Git Parameter ( 用于参数化构建中动态获取项目分支 )
Generic Webhook Trigger ( 用于解析 Webhook 传过来的参数 )
GitLab ( 用于推送构建结果给 GitLab )
添加 GitLab 凭据(jenkins)
首页 -> 凭据 -> 系统 -> 全局凭据 -> 添加凭据, 把上面 GitLab 中生成的 access token 填进去
配置 GitLab 连接
首页 -> 系统管理 -> 系统设置 -> Gitlab 配置项, 填入 GitLab 相关的配置, 后面配置项目时用到
Q15:gitlab提交代码自动触发jenkins例子
[root@gitlab meng2022]# git status
位于分支 dev
无文件要提交,干净的工作区
[root@gitlab meng2022]# git checkout main
切换到分支 'main'
[root@gitlab meng2022]# git status
位于分支 main
无文件要提交,干净的工作区
[root@gitlab meng2022]# ls
index.html README.md
[root@gitlab meng2022]# more index.html
2022-01-27_08:44:33
[root@gitlab meng2022]# echo "date %Y-%m-%d_%H:%M:%S" >index.html
[root@gitlab meng2022]# git add index.html
[root@gitlab meng2022]# git commit -m "index.html"
[main 67b446b] index.html
1 file changed, 1 insertion( ), 1 deletion(-)
[root@gitlab meng2022]# git push -u origin main
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 283 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://jenkinsci:meng2022@192.168.10.13/meng2022/meng2022.git
ddb9164..67b446b main -> main
分支 main 设置为跟踪来自 origin 的远程分支 main。
gitlab 配置
手动触发:
jenkins配置
pipeline:
BUILDDIR="./"
node ('master'){
stage "pull code"
git branch: 'main', credentialsId: 'fbee0110-2b57-4005-8bae-e14ca0a85148', url: 'http://192.168.10.13/meng2022/meng2022.git'
}
#gittest 提交测试
gittest.sh
#!/bin/bash
cd meng2022
git status
git checkout main
git status
ls
echo "date %Y-%m-%d_%H:%M:%S" >index.html
git add index.html
git commit -m "index.html"
git push -u origin main
cd ..
执行后Jenkins截图
Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved