gitlab+jenkins 搭建
繼前一篇gitlab,這一篇介紹jenkins搭建并與gitlab進行集成---這里不是詳細的步驟
環境
系統:centos 7.3
jenkins版本:jenkins-2.176.1-1.1.noarch
# vim /etc/selinux/config SELINUX=disabled # setenforce 0 # getenforce官方安裝文檔
https://pkg.jenkins.io/redhat-stable/
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key yum install jenkins # systemctl start jenkins http://**:8080/第一次打開界面后,會根據提示 添加
# cat /var/lib/jenkins/secrets/initialAdminPassword
選擇安裝插件--推薦安裝,全部成功
--這里如果遇到offline,詳細參考文章末尾處理
實例配置
Jenkins URL: http://*:8080/
創建用戶,實例配置后,進行使用jenkins
--插件管理
--憑據管理
?
?--創建任務
--github配置(如果這里添加添加報錯,詳細見文章末尾)
--構建觸發器
?--gitlab --user settings --access tokens
創建Personal Access Tokens=**************** # curl -X PUT --header "PRIVATE-TOKEN: *************" 'http://*****/api/v4/application/settings?allow_local_requests_from_hooks_and_services=true'創建gitlab hook
--RUL是在jenkins對應任務中的rul,token是上面generate生成的token
在sourcetree客戶端等執行git的一系列操作
然后push
在jenkins
?
目前就測試到這里
?--錯誤處理
1?
--運行:立即構建,控制臺輸出 --1> git fetch --tags --progress git@*:dba/mysql_test.git +refs/heads/*:refs/remotes/origin/* ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git fetch --tags --progress git@*:dba/mysql_test.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Permission denied, please try again. Permission denied, please try again. Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). fatal: Could not read from remote repository.解決
解決: --1 在gitlab添加ssh key user settings--ssh keys/ [root@jenkins ~]# cat .ssh/id_rsa.pub ##添加該密鑰 --2 在jenkins的工程 源碼管理-git-URL= git@**:root/hq_test.git credentials=root, [root@jenkins ~]# cat .ssh/id_rsa ##添加該密鑰?
2 offine處理
分別使用看誰能下載
wget https://updates.jenkins.io/update-center.json wget http://updates.jenkins.io/update-center.json看哪一個能ping通,就修改為哪一個,再重啟jenkins
# systemctl stop jenkins # systemctl start jenkins [root@localhost opt]# find / -name "hudson.model.UpdateCenter.xml" /home/data/jenkins/hudson.model.UpdateCenter.xml [root@localhost opt]# vim /home/data/jenkins/hudson.model.UpdateCenter.xml <?xml version='1.1' encoding='UTF-8'?> <sites><site><id>default</id><url>http://updates.jenkins.io/update-center.json</url></site> </sites>轉載于:https://www.cnblogs.com/yhq1314/p/11158701.html
總結
以上是生活随笔為你收集整理的gitlab+jenkins 搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于Xbox live及其在中国的使用
- 下一篇: Swift 协议protocol