[root@localhost src]# pwd /usr/local/src [root@localhost src]# tar xvf jdk-8u211-linux-x64.tar.gz
[root@localhost src]# ln -sv jdk1.8.0_211/ jdk [root@localhost src]# ln -sv /usr/local/src/jdk/bin/* /usr/bin/
[root@localhost src]# vim /etc/profile …… export JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
[root@localhost src]# source /etc/profile
[root@localhost src]# java -version java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
[root@localhost rpm]# ls jenkins-2.164.3-1.1.noarch.rpm [root@localhost rpm]# rpm -ivh jenkins-2.164.3-1.1.noarch.rpm warning: jenkins-2.164.3-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY Preparing... ################################# [100%] Updating / installing... 1:jenkins-2.164.3-1.1 ################################# [100%]
[root@localhost jenkins]# grep '^[a-Z]' /etc/sysconfig/jenkins JENKINS_HOME="/var/lib/jenkins" #jenkins的家目錄,保存着其構建的項目、安裝的插件、 JENKINS_JAVA_CMD="" JENKINS_USER="root" #默認是jenkins用戶,這裏將這裏改成root用戶,避免未來部署代碼到後端服務由於權限問題致使部署失敗 JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dcom.sun.management.jmxremote #options選項中開啓監控功能,爲zabbix等監控軟件提供一個監控接口 -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname="192.168.1.15"" JENKINS_PORT="8080" JENKINS_LISTEN_ADDRESS="" JENKINS_HTTPS_PORT="" JENKINS_HTTPS_KEYSTORE="" JENKINS_HTTPS_KEYSTORE_PASSWORD="" JENKINS_HTTPS_LISTEN_ADDRESS="" JENKINS_DEBUG_LEVEL="5" JENKINS_ENABLE_ACCESS_LOG="no" JENKINS_HANDLER_MAX="100" JENKINS_HANDLER_IDLE="20" JENKINS_ARGS=""
[root@localhost rpm]# systemctl start jenkins
[root@localhost rpm]# ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port …… LISTEN 0 50 :::8080 :::* users:(("java",pid=2739,fd=166)) ……
[root@localhost rpm]# cat /var/lib/jenkins/secrets/initialAdminPassword fb58302d30c34478b086244bd725bc68
2)再將jenkeys的服務器的公鑰添加到gitlab服務器
html
[root@jenkins ~]# git clone git@192.168.1.30:jie/web-page.git Cloning into 'web-page'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), 244 bytes | 0 bytes/s, done.
[root@jenkins ~]# ls anaconda-ks.cfg dump.rdb sentinel_26379.log web-page
[root@jenkins ~]# cat web-page/index.html <h1>welcom to my gitlab page!</h1>
[root@jenkins ~]# ls -a /var/lib/jenkins/workspace/website-html . .. .git index.html
[root@jenkins ~]# ssh-copy-id www@192.168.1.31
[root@jenkins ~]# ll /var/lib/jenkins/workspace/website-html/ total 16 -rw-r--r-- 1 root root 34 Jul 23 00:20 index.html -rw-r--r-- 1 root root 10240 Jul 23 00:20 index.tar.gz
[root@localhost html]# ll total 16 -rw-r--r-- 1 www www 34 Jul 23 00:20 index.html -rw-r--r-- 1 www www 10240 Jul 23 00:20 index.tar.gz
[root@jenkins ~]# openssl rand -hex 16 2fc11d619fe0c21facf6ddf71504a08e
或者直接curl [root@jenkins ~]# curl http://192.168.1.15:8080/job/develop/build?token=2fc11d619fe0c21facf6ddf71504a08e
[root@nginx ~]# git clone -b develop http://192.168.1.30/jie/web-page.git Cloning into 'web-page'... Username for 'http://192.168.1.30': jie Password for 'http://jie@192.168.1.30': remote: Enumerating objects: 18, done. remote: Counting objects: 100% (18/18), done. remote: Compressing objects: 100% (9/9), done. remote: Total 18 (delta 2), reused 0 (delta 0) Unpacking objects: 100% (18/18), done.
[root@nginx ~]# cd web-page/ [root@nginx web-page]# ls -a . .. .git index.html
[root@nginx web-page]# cat index.html <h1>welcom to my develop page</h1> [root@nginx web-page]# vim index.html <h1>welcom to my develop page</h1> <h2>welcom to my develop page</h2> <h3>welcom to my develop page</h3> <h4>welcom to my develop page</h4>
[root@nginx web-page]# git add index.html
[root@nginx web-page]# git commit -m 'audi_q7' [develop b560fe3] audi_q7 1 file changed, 3 insertions(+), 1 deletion(-)
[root@nginx web-page]# git push Username for 'http://192.168.1.30': jie Password for 'http://jie@192.168.1.30': Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 280 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: remote: To create a merge request for develop, visit: remote: http://192.168.1.30/jie/web-page/merge_requests/new?merge_request%5Bsource_branch%5D=develop remote: To http://192.168.1.30/jie/web-page.git de793ac..b560fe3 develop -> develop
root@nginx ~]# ll /usr/share/nginx/html/ total 16 -rw-r--r-- 1 www www 140 Jul 24 19:51 index.html -rw-r--r-- 1 www www 10240 Jul 24 19:51 index.tar.gz
[root@nginx ~]# systemctl status nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-07-24 19:51:12 CST; 4min 38s ago Process: 7582 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 7580 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 7578 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 7584 (nginx) CGroup: /system.slice/nginx.service ├─7584 nginx: master process /usr/sbin/nginx ├─7585 nginx: worker process └─7586 nginx: worker process