ÔõÑùʹÓÃJenkins×Ô¶¯°²ÅÅGit´úÂë
jenkinsÊÇÒ»¸öÊ¢ÐеĿªÔ´×Ô¶¯»¯Ð§ÀÍÆ÷¹¤¾ß£¬¿ÉÒÔÓÃÓÚÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅÓ¦ÓóÌÐò¡£Í¨¹ýjenkins£¬¿ÉÒÔÇáËɵØ×Ô¶¯»¯²âÊÔ£¬¹¹½¨ºÍ°²ÅÅ´úÂë¡£ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«Ñ§Ï°ÔõÑùʹÓÃjenkins×Ô¶¯°²ÅÅgit´úÂë¡£
×¼±¸ÊÂÇ飺
×°ÖÃJenkins
ÔÚÍâµØ»òÔ¶³ÌЧÀÍÆ÷ÉÏ×°ÖÃJenkins¡£×°ÖÃJenkinsºÜÊǼòÆÓ£¬Ö»Ðèƾָ֤ʾ¾ÙÐм´¿É¡£
×°ÖÃGit²å¼þ
·¿ªJenkins¿ØÖÆÃæ°å£¬µã»÷¡°²å¼þÖÎÀí¡±£¬ÔÚ¡°¿ÉÑ¡²å¼þ¡±ÖÐËÑË÷²¢×°ÖÃGit²å¼þ¡£
ÉèÖÃGit
ÔÚJenkinsÖÐÉèÖÃGit¡£ÐèÒª½«GitÉèÖÃΪJenkinsʹÓõÄÔ´´úÂë¿ØÖÆ¡£¿ÉÒÔÉèÖöà¸öGitÔ´´úÂë¿ØÖÆ¡£ÔÚJenkinsÃæ°åÖУ¬µã»÷¡°ÏµÍ³ÖÎÀí¡±£¬Ñ¡Ôñ¡°È«¾Ö¹¤¾ßÉèÖá±£¬ÔÚ¡°Git¡±²¿·ÖÖÐÌí¼ÓGitµÄ·¾¶ºÍ¿ÉÑ¡µÄÓû§ÃûºÍÃÜÂë¡£
½¨ÉèJenkins Job
ÔÚJenkinsÖн¨ÉèÒ»¸öеÄJob¡£µã»÷Jenkins¿ØÖÆÃæ°åÖеġ°Ð½¨Ê¹Ãü¡±£¬ÊäÈëʹÃüÃû³Æ²¢Ñ¡Ôñ¡°¹¹½¨Ò»¸ö×ÔÓÉÆøÑæÆøÑæµÄÈí¼þÏîÄ¿¡±¡£
ʵ¼ù²Ù×÷£º
ÔÚJenkinsÖÐÉèÖÃGitÔ´´úÂë¿ØÖÆ
ÔÚJenkins JobÖУ¬µã»÷¡°Ô´ÂëÖÎÀí¡±£¬Ñ¡ÔñGit×÷ΪԴ´úÂë¿ØÖÆϵͳ¡£½«Git¿ÍÕ»µÄURLºÍ·ÖÖ§ÐÅÏ¢ÌîÈëÏìÓ¦µÄÎı¾¿òÖС£
ÔÚ¡°¹¹½¨´¥·¢Æ÷¡±ÖУ¬Ñ¡Ôñ¡°ÂÖѯSCM¡±£¬ÉèÖÃÂÖѯʱ¼ä¾àÀ룬ÒÔ±ãJenkinsÔÚÌØ׼ʱ¼ä¾àÀëÄÚ×Ô¶¯¼ì²âÈκÎÔ´´úÂë±ä»»¡£
ÉèÖù¹½¨°ì·¨
ÔÚJenkins JobÖУ¬µã»÷¡°¹¹½¨°ì·¨¡±£¬Ìí¼Ó¡°Åú´¦ÀíÏÂÁ¹¹½¨°ì·¨£¬ÓÃÓÚ¹¹½¨´úÂë¡£
ÔÚ¡°Ö´ÐÐWindowsÅú´¦Àí¡±¹¹½¨°ì·¨ÖУ¬ÊäÈëÒÔÏÂÏÂÁ
git pull npm install npm run build
µÇ¼ºó¸´ÖÆ
ÕâЩÏÂÁ¼ì³öGit¿ÍÕ»µÄ×îа汾£¬×°ÖÃÐëÒªµÄÒÀÀµÏ²¢¹¹½¨Ó¦ÓóÌÐò¡£
×Ô¶¯Çø·Ö²âÊÔ°ì·¨
ÔÚJenkins JobÖУ¬µã»÷¡°¹¹½¨°ì·¨¡±£¬Ìí¼Ó¡°Åú´¦ÀíÏÂÁ¹¹½¨°ì·¨£¬ÓÃÓÚÖ´ÐвâÊÔ¡£
ÔÚ¡°Ö´ÐÐWindowsÅú´¦Àí¡±¹¹½¨°ì·¨ÖУ¬ÊäÈëÒÔÏÂÏÂÁ
npm run test
µÇ¼ºó¸´ÖÆ
ÕâЩÏÂÁÔËÐÐÓ¦ÓóÌÐòµÄ²âÊÔ£¬²¢ÌìÉú²âÊÔ±¨¸æ¡£
ÉèÖÃ×Ô¶¯°²ÅÅ
ÔÚJenkins JobÖУ¬µã»÷¡°ºóÖù¹½¨°ì·¨¡±£¬Ìí¼Ó¡°Deploy to Container¡±¹¹½¨°ì·¨¡£
ÔÚ¡°Deploy to Container¡±¹¹½¨°ì·¨ÖУ¬Ìîд°²ÅÅÐÅÏ¢£¬°üÀ¨Ð§ÀÍÆ÷URL£¬Óû§Ãû£¬ÃÜÂëµÈ¡£
µã»÷¡°Save¡±ÉúÑÄJenkins JobÉèÖá£
ÏÖÔÚ£¬µ±Ô´´úÂë±ä»»Ê±£¬Jenkins½«×Ô¶¯¹¹½¨ºÍ²âÊÔÓ¦ÓóÌÐò¡£Ò»µ©¹¹½¨ºÍ²âÊÔÀֳɣ¬Jenkins½«×Ô¶¯°²ÅÅÓ¦ÓóÌÐòµ½Ö¸¶¨Ð§ÀÍÆ÷ÉÏ¡£
½áÂÛ£º
ʹÓÃJenkins×Ô¶¯°²ÅÅGit´úÂëÊÇÒ»¸öÇ¿Ê¢¶ø¼òÆÓµÄÒªÁ죬¿ÉÒÔ½ÚԼʱ¼äºÍ¾«Éñ¡£Ê¹ÓôËÀú³Ì£¬Jenkins½«×Ô¶¯¹¹½¨£¬²âÊԺͰ²ÅÅÓ¦ÓóÌÐò£¬´Ó¶ø¼ÓËÙÁ˵ü´úºÍ°²ÅÅÁ÷³Ì¡£Ë¼Á¿½«´ËÀú³Ì¼¯³Éµ½ÄúµÄ¿ª·¢Á÷³ÌÖУ¬ÒÔʵÏÖ¸ü¿ì£¬¸ü¸ßÖÊÁ¿µÄ´úÂë½»¸¶¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃJenkins×Ô¶¯°²ÅÅGit´úÂëµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡