±³¾°
Ëæ×ÅÒµÎñÐèÇóµÄÑݽø£¬¹¤³ÌµÄ¸´ÔÓ¶È»áÖð½¥Ôö¼Ó£¬×Ô¶¯»¯µÄ¼ùÐÐÈÕÒæÇ¿ÁÒ¡£ÊÂʵÉÏ£¬¹¤³ÌµÄ×Ô¶¯»¯Ò»Ö±ÊÇÎÒÃÇŬÁ¦µÄÄ¿±ê£¬ÄÜÓÐЧÌá¸ßÎÒÃǵÄÉú²úЧÂÊ£¬×î´ó»¯¼õÉÙÈËΪ³ö´íµÄ¸ÅÂÊ£¬ÊµÏÖһЩ¸´ÔÓµÄÒµÎñÐèÇóÓ¦±ä¡£
³¡¾°ÈçÏ£¬¹«Ë¾ÏÖÔڵIJâÊÔÈËԱÿ´ÎÐèÒª²âÊÔа汾£¬¶¼ÐèÒª¿ª·¢ÈËÔ±´ò°ü£¬·Åµ½ftp£¬²âÊÔÈËԱȻºó´ÓftpÉÏ¿½±´µ½±¾µØ(»òÕßÓÃÊÖ»úµÄESÎļþ¹ÜÀíÆ÷)£¬ÔÙ°²×°¡£ÓÈÆäÁÙ½ü·¢°æµÄÒ»ÖÜ£¬¼¸ºõÿÌ춼Ҫа汾¡£ÕâÑùµÄ»°£¬ÓÐÁ½·½ÃæµÄÓ°Ï죺µÚÒ»£¬´ò¶ÏÁË¿ª·¢ÈËÔ±µÄ¿ª·¢½ø¶È;µÚ¶þ£¬¿ª·¢ÈËÔ±´ò°üЧÂʵÍÏ£¬ÓÈÆäÊÇios£¬²»Ë³µÄ»°£¬×ÜÊÇ´òµÄ²»¶Ô(¿ÉÄÜÊÇÖ¤ÊéµÄÎÊÌâ)¡£
Òª½â¾öÕâ¸öÎÊÌ⣬±ØÐëʵÏÖÒÆ¶¯¶ËÓ¦ÓõÄ×Ô¶¯»¯¹¹½¨¡£¾ßÌå˵À´¾ÍÊÇ£¬Ê¹ÓóÖÐø¼¯³É(CI)ϵͳjenkins£¬×Ô¶¯¼ì²â²¢ÀÈ¡×îдúÂ룬×Ô¶¯´ò°üandroidµÄapkºÍiosµÄipa£¬×Ô¶¯ÉÏ´«µ½ÄÚ²â·Ö·¢Æ½Ì¨ÆÑ¹«Ó¢ÉÏ¡£(½ÓÏÂÀ´£¬²âÊÔÈËÔ±Ö»Òª´ò¿ªÒ»¸ö(»ò¶à¸ö)¹Ì¶¨µÄÍøÖ·£¬É¨Ãèһ϶þάÂ룬¾ÍÄÜÏÂÔØ×îеİ汾ÁË¡)
»·¾³
ÒòΪҪ±àÒëios£¬ËùÒÔÑ¡ÔñMac OSX 10.11.1¡£
ÎÞÂÛÊÇÄĸö²Ù×÷ϵͳ£¬jenkinsµÄÅäÖÃÊÇÒ»ÑùµÄ¡£
°²×°Jenkins
¹ÙÍøµØÖ·£ºhttp://jenkins-ci.org/
// ʹÓÃbrew°²×° brew install jenkins // Æô¶¯£¬Ö±½ÓÔËÐÐjenkins¼´¿ÉÆô¶¯·þÎñ jenkins |
ĬÈÏ·ÃÎÊhttp://localhost:8080/, ¿É½øÈëjenkinsÅäÖÃÒ³Ãæ¡£
°²×°JenkinsÏà¹Ø²å¼þ
µã»÷ϵͳ¹ÜÀí>¹ÜÀí²å¼þ>¿ÉÑ¡²å¼þ£¬¿ÉËÑË÷ÒÔϲå¼þ°²×°
git²å¼þ(GIT plugin)
ssh²å¼þ(SSH Credentials Plugin)
Gradle²å¼þ(Gradle plugin) ¨C androidרÓÃ
Xcode²å¼þ(Xcode integration) ¨C iosרÓÃ
н¨Job
Ö÷Ò³Ãæ£¬Ð½¨ -> ¹¹½¨Ò»¸ö×ÔÓÉ·ç¸ñµÄÈí¼þÏîÄ¿¼´¿É¡£
¶ÔÓÚÀàËÆµÄÏîÄ¿£¬¿ÉÒÔÑ¡Ôñ -> ¸´ÖÆÒÑÓеÄItem£¬Òª¸´ÖƵÄÈÎÎñÃû³ÆÀïÊäÈëÆäËûjobµÄÊ××Ö·û»áÓÐÖÇÄÜÌáʾ¡£
ÅäÖÃgit²Ö¿â
Èç¹û°²×°ÁËgit²å¼þ£¬ÔÚÔ´Âë¹ÜÀí»á³öÏÖGit£¬Ñ¡ÖÐÖ®ºó£º
Repositories -> https://github.com/openproject/ganchai,
Èç¹ûÊÇssh»¹ÒªÅäÖÃCredentials¡£
Branch -> */master£¬Ñ¡¶¨Ò»¸öÒª±àÒëµÄ·ÖÖ§´úÂë¡£
ÈçÏ£º

Èç¹ûÊÇ˽ÓеIJֿâ(±ÈÈçgit://xxxxx.git),µã»÷Credentials
¨C Add£¬µ¯³ö¶Ô»°¿ò£¬ÅäÖÃsshkey×î¼òµ¥ÁË£º

ÅäÖÃ×Ô¶¯ÀÈ¡×îдúÂë
ÔÚ¹¹½¨´¥·¢Æ÷ÖУ¬ÓÐÁ½ÖÖ×Ô¶¯ÀÈ¡´úÂë²¢±àÒëµÄ²ßÂÔ:
1. ÉèÖÃPoll SCM£¬ÉèÖö¨Ê±Æ÷£¬¶¨Ê±¼ì²é´úÂë¸üУ¬ÓиüÐÂÔò±àÒ룬·ñÔò²»±àÒë(ÎÒÔÝʱÓõÄÊÇÕâ¸ö)¡£
2.Ò²¿ÉÒÔÉèÖÃBuild periodically£¬ÖÜÆÚÐÔµÄÖ´ÐбàÒëÈÎÎñ¡£

¹ØÓÚ¶¨Ê±Æ÷µÄ¸ñʽ£¬ÎÒÖ»ÄÜ´ÓÍøÉÏÕª³Ò»¶ÎÉÔ΢¿¿Æ×Ò»µãµÄ˵Ã÷£º
This field follows the syntax of cron (with minor differences).
Specifically, each line consists of 5 fields separated by TABor whitespace: MINUTE HOUR DOM MONTH DOW MINUTE Minutes within the hour (0-59) HOUR The hour of the day (0-23) DOM The day of the month (1-31) MONTH The month (1-12) DOW The day of the week (0-7) where 0 and 7 are Sunday. To specify multiple values for one field, the following
operators are available. In the order of precedence, * '*' can be used to specify all valid values. * 'M-N' can be used to specify a range, such as "1-5" * 'M-N/X' or '*/X' can be used to specify skips of X''s
value through the range, such as "*/15" in the MINUTE field
for"0,15,30,45" and "1-6/2" for "1,3,5" * 'A,B,...,Z' can be used to specify multiple values,
such as "0,30" or "1,3,5" Empty lines and lines that start with '#' will be ignored
as comments. In addition, @yearly, @annually, @monthly, @weekly, @daily,
@midnight, @hourly are supported. |
¾ÙÁ½¸öÀý×Ó£º
1.// every minute
2.* * * * *
3.// every 5 mins past the hour
4.5 * * * *
ÅäÖÃgradle ¨C androidרÓÃ
ÇëiosµÄÅóÓÑÃÇÇëÆ®¹ý.
Èç¹û°²×°gradle²å¼þ³É¹¦µÄ»°£¬Ó¦¸Ã»á³öÏÖÏÂͼµÄInvoke Gradle
script£¬ÅäÖÃÒ»ÏÂ:

${WORKSPACE}±íʾµ±Ç°jobϵÄworkspaceĿ¼£¬Ö÷ÒªÊÇ´æ·Å´úÂë¡£¸ü¶àµÄ»·¾³±äÁ¿Çë²Î¿¼ÎÄÄ©¸½Â¼¡£
ÕâÑù£¬¾ÍÄÜ×Ô¶¯ÔÚprojectϵÄappµÄbuild/outputs/apkÏÂÉú³ÉÏàÓ¦µÄapk.
±àÒëʧ°Ü?¿ÉÄÜÒª½â¾öÒÔÏÂ2¸öÎÊÌ⣺
1.gradleûÅäÖû·¾³±äÁ¿¡£
±ÈÈçÎÒÔÚ/etc/profileÖÐÅäÖÃÒ»ÏÂGRADLE_HOME:
export GRADLE_HOME='/home/jay/.gradle/wrapper/dists/gradle-2.2.1-all/c64ydeuardnfqctvr1gm30w53/gradle-2.2.1' export PATH=$GRADLE_HOME/bin:$PATH |
2.ÕÒ²»µ½local.propertiesÖÐsdk¶¨Òå¡£
ÒòΪһ°ãÀ´Ëµlocal.properties²»»áÌí¼Óµ½°æ±¾¿â¡£ËùÒÔÐèÒªÊÖ¶¯copyµ½${WORKSPACE}ϵÄProjectĿ¼ÏÂ(¿É²Î¿¼×Ô¼ºAndroid
Studio¹¤³Ì½á¹¹)¡£
¹ØÓÚlocal.propertiesµÄ¶¨Ò壬ÕâÀï¼Ç¼һÏ£¬×ö¸ö±¸·Ý£º
sdk.dir=xx/xx/android-sdk |
ÔÙ±àÒëÒ»°ã¾Í»á±àÒë³É¹¦£¬µ±È»µ±ÄÇЩµÚÈý·½¿âÐèÒªÖØÐÂÏÂÔØµÄ»°£¬±àÒë¿ÉÄÜ»áºÜÂý¡£
ÅäÖÃxcode ¨C iosרÓÃ
ÇëandroidµÄͬѧÃÇÆ®¹ý¡£
°²×°Xcode²å¼þºó£¬¿É¿´µ½ÈçÏÂͼ½çÃæ£¬²¢ÅäÖãº

ÕâÀïÓÐÁ½¸öµØ·½ÐèҪעÒâ¡£
1.Ç©Ãû
2.ÐèÒªShared SchemaÎļþ.
ÉÏ´«µ½ÆÑ¹«Ó¢Æ½Ì¨
ÔÚ¹ÙÍøÎĵµÀïÓÐ˵Ã÷£¬Í¨¹ýlinuxƽ̨ÉÏ´«appµÄ¹Ø¼ü´úÂë
curl -F "file=@/tmp/example.ipa" -F "uKey=" -F "_api_key=" http://www.pgyer.com/apiv1/app/upload |
¾ßÌåÀ´Ëµ£¬
# ÏȰÑ${version}¿´³Év1.0°É curl -F "file=@/home/xxx/release/ganchai-release-${version}-0101-dev.
apk" -F "uKey=231xxxxe6" -F"_api_key=0xxxx499" -F "publishRange=2" http://www.pgyer.com/apiv1/app/upload |
ÕâÑù¾ÍÍê³ÉÒ»¸öappÉÏ´«µ½ÆÑ¹«Ó¢ÁË¡£
ʵ¼ÊÉÏ£¬ÎÒÃÇ¿ÉÄÜ»áÃæ¶Ô¸ü¸´Ôӵij¡¾°£¬±ÈÈçÉÏÃæµÄ${version}, ¶øversion¶¨ÒåÓÚbuild.gradleÈçÏ£º
ext { compileSdkVersion = 22 buildToolsVersion = "23.0.1" minSdkVersion = 10 targetSdkVersion = 22 versionCode = 1111 versionName = "v1.2.0.0" } |
µÃÏë°ì·¨¶Áµ½versionName, È»ºóÆ´³ö×îÖÕµÄÎļþÃû£¬ÕâÑùÏ´ΰ汾Éý¼¶ÁËÖ®ºóÒ²Äܶ¯Ì¬µÄÉÏ´«appµ½ÆÑ¹«Ó¢ÁË¡£
# ʹÓÃsedÃüÁî¶ÁÈ¡£¬Ê¹ÓÃcutÇи×îÖÕ¶¯Ì¬¶ÁÈ¡µ½versionName version=`sed -n '21,1p' ${WORKSPACE}/xxx/build.gradle | cut -c20-27` |
ÕâÊÇandroidµÄapkÉÏ´«¹ý³Ì£¬ÏàÓ¦µÄ£¬iosÊÇÉÏ´«ipa£¬·½·¨ÊÇÒ»ÑùµÄ£¬²»ÔÙ׸Êö¡£
С½á
°Ñ¿ª·¢ÈËÔ±·¢²¼°æ±¾µÄ¹¤×÷×Ô¶¯»¯Ö®ºó£¬Èç´ËÒ»À´£¬·½±ãÁ˲âÊÔÈËÔ±ËæÊ±ÀÈ¡²¢¹¹½¨×îа汾£¬¸ü½â·ÅÁË¿ª·¢ÈËÔ±×Ô¼ºµÄ·¢°æ±¾µÄ¹¤×÷£¬Ò»¸ö×Ö£¬ÉÆ!
¸½Â¼
jenkinsÖж¨ÒåµÄÄÇЩ»·¾³±äÁ¿£º
The following variables are available to shell scripts BUILD_NUMBER The current build number, such as "153" BUILD_ID The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss) BUILD_DISPLAY_NAME The display name of the current build, which is something like "#153" by default. JOB_NAME Name of the project of this build, such as "foo" or "foo/bar". (To strip off folder
paths from a Bourne shell script, try:${JOB_NAME##*/}) BUILD_TAG String of "jenkins-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource
file, a jar file, etc for easier identification. EXECUTOR_NUMBER The unique number that identifies the current executor (among executors of the
same machine) that¡¯s carrying out thisbuild. This is the number you see in the
"build executor status", except that the number starts from 0, not 1. NODE_NAME Name of the slave if the build is on a slave, or "master" if run on master NODE_LABELS Whitespace-separated list of labels that the node is assigned. WORKSPACE The absolute path of the directory assigned to the build as a workspace. JENKINS_HOME The absolute path of the directory assigned on the master node for Jenkins
to store data. JENKINS_URL Full URL of Jenkins, like http://server:port/jenkins/ (note: only available
if Jenkins URL set in system configuration) BUILD_URL Full URL of this build, like http://server:port/jenkins/job/foo/15/
(Jenkins URL must be set) JOB_URL Full URL of this job, like http://server:port/jenkins/job/foo/
(Jenkins URL must be set) SVN_REVISION Subversion revision number that's currently checked out to the workspace,
such as "12345" SVN_URL Subversion URL that's currently checked out to the workspace. |
|