UbuntuϵͳÉÏÔõôװÖúÍʹÓÃgitlab
Ò»¡¢Ç°ÑÔ
Ìá¼° Git£¬Ðí¶à³ÌÐòÔ±ÃǶ¼ÖªµÀ¡£¶ø GitLab ÔòÊÇÒ»¸ö»ùÓÚ Git µÄ¿ªÔ´Æ½Ì¨£¬Ö¼ÔÚΪÍŶÓÌṩ´úÂëÍйܡ¢°æ±¾ÖÎÀí¡¢×Ô¶¯»¯²âÊÔ¡¢CI/CD µÈһϵÁÐЧÀÍ¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚ Ubuntu ϵͳÉÏ×°Öà GitLab ²¢¾ÙÐлù±¾Ê¹Óá£
¶þ¡¢×°ÖÃ GitLab
×°ÖÃÒÀÀµÏî
ÔÚ×°Öà GitLab Ç°£¬ÐèҪװÖúÃһЩÒÀÀµÏî¡£ÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁ
sudo apt update sudo apt install -y curl openssh-server ca-certificates tzdata perl
µÇ¼ºó¸´ÖÆ
Ìí¼Ó GitLab GPG ÃÜÔ¿
±à¼ /etc/apt/sources.list.d/gitlab-ce.list Îļþ£¬²¢Ð´ÈëÒÔÏÂÄÚÈÝ£º
deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu bionic main
µÇ¼ºó¸´ÖÆ
ÉúÑIJ¢Í˳öÎļþ£¬È»ºóÊäÈëÒÔÏÂÏÂÁ
curl https://packages.gitlab.com/gpg.key | sudo apt-key add -
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁÌí¼Ó GitLab GPG ÃÜÔ¿¡£
×°ÖÃ GitLab CE
ÊäÈëÒÔÏÂÏÂÁî×°Öà GitLab£º
sudo apt update sudo apt install -y gitlab-ce
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬ÊäÈëÒÔÏÂÏÂÁîÆô¶¯ GitLab£º
sudo gitlab-ctl reconfigure
µÇ¼ºó¸´ÖÆ
ÔÚÕû¸öÀú³ÌÖУ¬ÐèÒªÆÚ´ýÒ»¶Îʱ¼ä¡£Ò»µ© reconfigure Íê±Ï£¬GitLab ½«»áÆô¶¯¡£ÔÚä¯ÀÀÆ÷Öлá¼ûЧÀÍÆ÷ IP µØµã»òÓòÃû£ºhttp://SERVER_IP_OR_DOMAIN£¬Õâ¸öʱ¼ä½«¿´µ½ GitLab µÄ½Ó´ýÒ³Ã棬ÌåÏÖÒÑ×°ÖÃÀֳɡ£
Èý¡¢Ê¹Óà GitLab
¾ÓÉÉÏÃæµÄ°ì·¨£¬GitLab ÒѾװÖÃÀÖ³ÉÁË£¬ÏÂÃ潫¼òÆÓÏÈÈÝÔõÑù¾ÙÐÐ GitLab µÄ»ù±¾Ê¹Óá£
½¨ÉèÒ»¸öÐÂÏîÄ¿
Ê×ÏÈ£¬ÔÚ GitLab Öн¨ÉèÒ»¸öÐÂÏîÄ¿¡£µÇ¼ GitLab ºó£¬µã»÷×ó²à²Ëµ¥À¸Öеġ°Ð½¨ÏîÄ¿¡±£¬½øÈ롰н¨ÏîÄ¿¡±Ò³Ãæ¡£ÔÚ¸ÃÒ³ÃæÖУ¬ÌîдÏîÄ¿Ãû³Æ¡¢ÏîÄ¿ÐÎò£¬È»ºóµã»÷¡°½¨ÉèÏîÄ¿¡±°´Å¥¼´¿É¡£
¿Ë¡ÏîÄ¿
¿Ë¡ÏîÄ¿ÊÇÖ¸½«Ô¶³Ì Git ¿ÍÕ»ÖеĴúÂ븴ÖƵ½ÍâµØ¿ª·¢»úеÉÏ¡£ÔÚ GitLab ÖУ¬ÓÐÁ½ÖÖ¿Ë¡ÏîÄ¿µÄ·½·¨£º
HTTP/HTTPS ·½·¨£¬Ê¹Óø÷½·¨¿Éͨ¹ý https À´ÀÈ¡´úÂ룬ÀýÈ磺
git clone https://gitlab.com/<user>/<project>.git</project></user>
µÇ¼ºó¸´ÖÆ
SSH ·½·¨£¬Ê¹Óø÷½·¨ÐèÒªÔÚ GitLab ÖÐÌìÉú SSH ÃÜÔ¿£¬È»ºó½« SSH ÃÜÔ¿Ìí¼Óµ½ÍâµØ»úеÖС£ÀýÈ磺
git clone git@gitlab.com:<user>/<project>.git</project></user>
µÇ¼ºó¸´ÖÆ
½¨Éè·ÖÖ§
ÔÚ GitLab ÖУ¬¿ÉÒÔ½¨Éè¶à¸ö·ÖÖ§ÒԱ㿪·¢Ö°Ô±ÃǸüºÃµØÏàÖú¿ª·¢¡£ÔÚ GitLab ÖУ¬¿ÉÒÔ½¨ÉèеķÖÖ§²¢½«´úÂëÍÆË͵½¸Ã·ÖÖ§ÉÏ¡£ÔÚÏîÄ¿Ò³ÃæÖУ¬µã»÷¡°·ÖÖ§¡±°´Å¥£¬È»ºóÊäÈëÒª½¨ÉèµÄ·ÖÖ§Ãû³ÆºÍÐÎò£¬×îºóµã»÷¡°½¨Éè·ÖÖ§¡±°´Å¥¼´¿É¡£
Ìá½»½ÓÂë
ÔÚ¿ª·¢ÖУ¬Ã¿´ÎÐ޸ĺó¶¼ÐèÒªÌá½»½ÓÂë¡£ÔÚ GitLab ÖУ¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÏòÔ¶³Ì¿ÍÕ»Ìá½»½ÓÂ룺
git add . git commit -m "commit message" git push origin master
µÇ¼ºó¸´ÖÆ
ÒÔÉÏÏÂÁÏòÔ¶³Ì Git ¿ÍÕ»µÄ master ·ÖÖ§ÍÆËÍ´úÂë¡£
½¨Éè Merge Request
ÔÚ GitLab ÖУ¬¿ÉÒÔ½¨Éè Merge Request ÒÔ±ã¾ÙÐдúÂëÉó²éºÍºÏ²¢¡£ÔÚÏîÄ¿Ò³ÃæÖУ¬µã»÷¡°Merge Request¡±°´Å¥£¬È»ºóÊäÈëÆúÏÇëÇóÃû³ÆºÍÐÎò£¬×îºóµã»÷¡°Ìá½»Merge Request¡±°´Å¥¼´¿É¡£
CD/CI
GitLab »¹ÌṩÁË CD/CI µÈ×Ô¶¯»¯¹¦Ð§£¬Ê¹ÓÃÕß¿ÉÒÔÔÚ GitLab Öн¨Éè Pipeline£¬¶ÔÏîÄ¿¾ÙÐÐÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ¡£
ËÄ¡¢×ܽá
±¾ÎÄÏÈÈÝÁËÔõÑùÔÚ Ubuntu ϵͳÉÏ×°Öà GitLab£¬²¢¼òÆÓÏÈÈÝÁË GitLab µÄ»ù±¾Ê¹Óá£ËäÈ»£¬ÔÚÏÖʵӦÓõ±ÖУ¬GitLab µÄ¹¦Ð§ÉÐÓÐÐí¶à£¬¶ÁÕß¿ÉÒÔÍŽáÏÖʵÐèÇóȥ̽Ë÷ GitLab ¸ü¶àµÄÌØÕ÷¡£
ÒÔÉϾÍÊÇUbuntuϵͳÉÏÔõôװÖúÍʹÓÃgitlabµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡