文中用到的安装包都已经上传到百度网盘,下载地址在文章底部(还没传...)
前置条件:
为了节约配置时间,在正式配置前,应该先做好如下准备:
首先先把整个流程仔仔细细的看3遍,确认对配置整体的流程,配置时要注意点都有一个大概的印象。起码知道配置到这一步时,应该注意哪些点。切忌一上来就照着博客配置,这样非常容易掉进各种奇葩的坑里。
然后确认你需要的硬件配置是否都到位了,账号权限等需要和他人对接才能有结果的事,最好也在正式配置前搞定。比如我这次配置到一半的时候,代码仓库迁移了,于是又找配管开账号,配权限,耽误了不少时间,也浪费时间和精力
最后,做好会遇到各种奇葩问题的心理准备,遇到问题别惊慌,仔细分析错误提示,参阅网上一些前辈分享的经验,问题总能得到解决的。
安装JDK
在官网下载完成后点击安装包:jdk-8u191-macosx-x64.dmg,
按提示即可完成安装。 并不需要特别配置环境变量,安装完成后,环境变量自动配置好了。在命令行敲javac 和 java -version进行验证
验证javac
验证java -version
打开Finder,可以在下图所示的路径中找到安装好的jdk-11.0.2.jdk:
其中Contents下的Home文件夹,是该JDK的根目录
/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
其中:
bin目录下存放JDK用于开发的一些终端命令工具。常见的工具如:
“javac”的作用是将java源文件编译为class文件(即自解码文件);
“java”命令的作用是运行class文件。
db目录下是java开发的一个开源的关系型数据库;
include目录下是一些C语言的头文件;
jre目录下JDK所依赖的java运行时;
lib目录下存放JDK开发工具所依赖的一些库文件;
man目录下存放JDK开发工具的说明文档。
安装tomcat
- 下载Tomcat
打开https://tomcat.apache.org下载Tomcat。
可以选zip或者tar.gz文件下载。我下载的是zip文件
将下载好的文件解压,改成Tomcat8文件夹,放入~/Library/中。
启动Tomcat
切换当前目录到~/Library/Tomcat/bin。
cd ~/Library/Tomcat/bin
运行:
./startup.sh
出现权限错误:
Permission denied
更改文件读写权限:
sudo chmod 755 *.sh
再次运行:
./startup.sh
出现Tomcat started即表示启动成功
Using CATALINA_BASE: /Users/****/Library/Tomcat Using CATALINA_HOME: /Users/****/Library/Tomcat Using CATALINA_TMPDIR: /Users/****/Library/Tomcat/temp Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home Using CLASSPATH: /Users/****/Library/Tomcat/bin/bootstrap.jar:/Users/****/Library/Tomcat/bin/tomcat-juli.jar Tomcat started.
此时,可以测试是否安装完成:
在浏览器中,打开:http://localhost:8080/。出现如下图网站即安装成功
- 关闭Tomcat
./shutdown.sh
设置tomcat开机自启动
1.到/Library/LaunchDaemons这个目录下使用 sudo touch tomcat.plist 新增tomcat.plist, 这个指令会要求输入管理员密码(如果已经sudo su切换到root用户,则不需要)
sh-3.2# touch tomcat.plist
新建文件后的目录结构如图:
sh-3.2# ls com.oracle.java.Helper-Tool.plist tomcat.plist
2.使用nano tomcat.plist , 编辑tomcat.plist, 內容如下:
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 4 5 <plist version="1.0"> 6 7 <dict> 8 9 <key>Disabled</key> 10 11 <false/> 12 13 <key>UserName</key> 14 15 <string>mac用户名</string> 16 17 <key>Label</key> 18 19 <string>tomcat</string> 20 21 <key>KeepAlive</key> 22 23 <dict> 24 25 <key>NetworkState</key> 26 27 <true/> 28 29 </dict> 30 31 <key>ProgramArguments</key> 32 33 <array> 34 35 <string>tomcat路径/bin/catalina.sh</string> 36 37 <string>run</string> 38 39 </array> 40 41 <key>EnvironmentVariables</key> 42 43 <dict> 44 45 <key>JAVA_HOME</key> 46 47 <string>java_home路径</string> 48 49 </dict> 50 51 <key>RunAtLoad</key> 52 53 <true/> 54 55 <key>StandardOutPath</key> 56 57 <string>/Library/Tomcat8/logs/launchd.stdout</string> 58 59 <key>StandardErrorPath</key> 60 61 <string>/Library/Tomcat8/logs/launchd.stderr</string> 62 63 </dict> 64 65 </plist>
3.注意:
以上自行修改成tomcat的配置
其中java_home路径可以通过该命令得到:
/usr/libexec/java_home
4.手动测试Launchd , 启动指令为
launchctl load tomcat.plist
5.若打开浏览器输入http://localhost:8080,展示熟悉的界面,启动成功
6.重新启动机器,打开浏览器输入http://localhost:8080,则说明设置tomcat开机启动成功
先留个问号,为什么每次启动tomcat就会出现这个java的图标呢?
参照:
https://blog.csdn.net/feibozhulang/article/details/43735177
https://blog.csdn.net/natejeams/article/details/60869521
安装jenkins.war
下载jenkins.war包
将jenkins.war
包放于tomcat
的webapps
目录下
命令行的目录是:
/Library/Tomcat8/webapps
由于之前已经配置了tomcat开机自启动,这里直接打开浏览器访问http://localhost:8080/jenkins
即可进入jenkins
配置页面。
如果没有配置tomcat开机自启动,则可以手动到tomcat的安装目录,先启动tomcat。详情可以参照之前写的文章:Mac os安装tomcat并配置开机自启动
接下来就开始配置jenkins,jenkins的配置,参照这一篇文章即可:MAC 安装jenkins
里程碑
tomcat+jenkins搭建完成:
安装homebrew
homebrew是macOS 缺失的软件包的管理器
安装homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Homebrew 能干什么?
使用 Homebrew 安装 Apple 没有预装但 你需要的东西。
$ brew install wget
Homebrew 会将软件包安装到独立目录,并将其文件软链接至 /usr/local
。
1 $ cd /usr/local 2 $ find Cellar 3 Cellar/wget/1.16.1 4 Cellar/wget/1.16.1/bin/wget 5 Cellar/wget/1.16.1/share/man/man1/wget.1 6 7 $ ls -l bin 8 bin/wget -> ../Cellar/wget/1.16.1/bin/wget
Homebrew 不会将文件安装到它本身目录之外,所以您可将 Homebrew 安装到任意位置。
安装python3运行环境
https://www.cnblogs.com/meng1314-shuai/p/9031686.html
安装前先homebrew搜索一下是否已经存在python3的包:
brew search python3
如图:
已经存在,我们可以直接安装了:
brew install python3
开始安装:
安装成功:
1 Mac mini:~ wangju$ brew install python3 2 ==> Installing dependencies for python: gdbm, openssl, readline, sqlite and xz 3 ==> Installing python dependency: gdbm 4 ==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.mojave.bottle.1 5 ######################################################################## 100.0% 6 ==> Pouring gdbm-1.18.1.mojave.bottle.1.tar.gz 7 ? /usr/local/Cellar/gdbm/1.18.1: 20 files, 586.8KB 8 ==> Installing python dependency: openssl 9 ==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2s.mojave.bottl 10 ==> Downloading from https://akamai.bintray.com/c4/c4a762d719c2be74ac686f1aafabb 11 ######################################################################## 100.0% 12 ==> Pouring openssl-1.0.2s.mojave.bottle.tar.gz 13 ==> Caveats 14 A CA file has been bootstrapped using certificates from the SystemRoots 15 keychain. To add additional certificates (e.g. the certificates added in 16 the System keychain), place .pem files in 17 /usr/local/etc/openssl/certs 18 19 and run 20 /usr/local/opt/openssl/bin/c_rehash 21 22 openssl is keg-only, which means it was not symlinked into /usr/local, 23 because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. 24 25 If you need to have openssl first in your PATH run: 26 echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile 27 28 For compilers to find openssl you may need to set: 29 export LDFLAGS="-L/usr/local/opt/openssl/lib" 30 export CPPFLAGS="-I/usr/local/opt/openssl/include" 31 32 ==> Summary 33 ? /usr/local/Cellar/openssl/1.0.2s: 1,795 files, 12.0MB 34 ==> Installing python dependency: readline 35 ==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.0_1.mojave.bot 36 ==> Downloading from https://akamai.bintray.com/fa/faab004773e6449dd97971311cb62 37 ######################################################################## 100.0% 38 ==> Pouring readline-8.0.0_1.mojave.bottle.tar.gz 39 ==> Caveats 40 readline is keg-only, which means it was not symlinked into /usr/local, 41 because macOS provides the BSD libedit library, which shadows libreadline. 42 In order to prevent conflicts when programs look for libreadline we are 43 defaulting this GNU Readline installation to keg-only. 44 45 For compilers to find readline you may need to set: 46 export LDFLAGS="-L/usr/local/opt/readline/lib" 47 export CPPFLAGS="-I/usr/local/opt/readline/include" 48 49 ==> Summary 50 ? /usr/local/Cellar/readline/8.0.0_1: 48 files, 1.5MB 51 ==> Installing python dependency: sqlite 52 ==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.29.0.mojave.bottle 53 ==> Downloading from https://akamai.bintray.com/5f/5f2f8f36a8d13733b0374ac39bdcd 54 ######################################################################## 100.0% 55 ==> Pouring sqlite-3.29.0.mojave.bottle.tar.gz 56 ==> Caveats 57 sqlite is keg-only, which means it was not symlinked into /usr/local, 58 because macOS provides an older sqlite3. 59 60 If you need to have sqlite first in your PATH run: 61 echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile 62 63 For compilers to find sqlite you may need to set: 64 export LDFLAGS="-L/usr/local/opt/sqlite/lib" 65 export CPPFLAGS="-I/usr/local/opt/sqlite/include" 66 67 ==> Summary 68 ? /usr/local/Cellar/sqlite/3.29.0: 11 files, 3.9MB 69 ==> Installing python dependency: xz 70 ==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.4.mojave.bottle.tar. 71 ==> Downloading from https://akamai.bintray.com/01/010667293df282c8bceede3bcd369 72 ######################################################################## 100.0% 73 ==> Pouring xz-5.2.4.mojave.bottle.tar.gz 74 ? /usr/local/Cellar/xz/5.2.4: 92 files, 1MB 75 ==> Installing python 76 ==> Downloading https://homebrew.bintray.com/bottles/python-3.7.4.mojave.bottle. 77 ==> Downloading from https://akamai.bintray.com/81/81fc6e5914a16387bd09387ce08e9 78 ######################################################################## 100.0% 79 ==> Pouring python-3.7.4.mojave.bottle.tar.gz 80 ==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install 81 ==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install 82 ==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install 83 ==> Caveats 84 Python has been installed as 85 /usr/local/bin/python3 86 87 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to 88 `python3`, `python3-config`, `pip3` etc., respectively, have been installed into 89 /usr/local/opt/python/libexec/bin 90 91 If you need Homebrew's Python 2.7 run 92 brew install python@2 93 94 You can install Python packages with 95 pip3 install <package> 96 They will install into the site-package directory 97 /usr/local/lib/python3.7/site-packages 98 99 See: https://docs.brew.sh/Homebrew-and-Python 100 ==> Summary 101 ? /usr/local/Cellar/python/3.7.4: 3,865 files, 60MB 102 ==> Caveats 103 ==> openssl 104 A CA file has been bootstrapped using certificates from the SystemRoots 105 keychain. To add additional certificates (e.g. the certificates added in 106 the System keychain), place .pem files in 107 /usr/local/etc/openssl/certs 108 109 and run 110 /usr/local/opt/openssl/bin/c_rehash 111 112 openssl is keg-only, which means it was not symlinked into /usr/local, 113 because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries. 114 115 If you need to have openssl first in your PATH run: 116 echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile 117 118 For compilers to find openssl you may need to set: 119 export LDFLAGS="-L/usr/local/opt/openssl/lib" 120 export CPPFLAGS="-I/usr/local/opt/openssl/include" 121 122 ==> readline 123 readline is keg-only, which means it was not symlinked into /usr/local, 124 because macOS provides the BSD libedit library, which shadows libreadline. 125 In order to prevent conflicts when programs look for libreadline we are 126 defaulting this GNU Readline installation to keg-only. 127 128 For compilers to find readline you may need to set: 129 export LDFLAGS="-L/usr/local/opt/readline/lib" 130 export CPPFLAGS="-I/usr/local/opt/readline/include" 131 132 ==> sqlite 133 sqlite is keg-only, which means it was not symlinked into /usr/local, 134 because macOS provides an older sqlite3. 135 136 If you need to have sqlite first in your PATH run: 137 echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile 138 139 For compilers to find sqlite you may need to set: 140 export LDFLAGS="-L/usr/local/opt/sqlite/lib" 141 export CPPFLAGS="-I/usr/local/opt/sqlite/include" 142 143 ==> python 144 Python has been installed as 145 /usr/local/bin/python3 146 147 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to 148 `python3`, `python3-config`, `pip3` etc., respectively, have been installed into 149 /usr/local/opt/python/libexec/bin 150 151 If you need Homebrew's Python 2.7 run 152 brew install python@2 153 154 You can install Python packages with 155 pip3 install <package> 156 They will install into the site-package directory 157 /usr/local/lib/python3.7/site-packages
从上面的安装信息我们可以看到python被安装在目录 /usr/local/bin/python3(第144 145行)
输入python3验证python安装成功
参照文档:
https://www.cnblogs.com/meng1314-shuai/p/9031686.html
安装python虚拟环境
virtualenv是一个可以在同一计算机中隔离多个python版本的工具。有时,两个不同的项目可能需要不同版本的python,如 python2.7 / python3.6 ,但是如果都装到一起,经常会导致问题。virtualenv能够用于创建独立的Python虚拟环境,多个Python相互独立,互不影响。
virtualenvwrapper这个软件包可以让我们管理虚拟环境变得更加简单。不用再跑到某个目录下通过virtualenv来创建虚拟环境,并且激活的时候也要跑到具体的目录下去激活。
下面介绍安装python虚拟环境的方法:
使用pip安装包前,先更新pip。
pip3 install --upgrade pip
1. 安装virtualenv、virtualenvwrapper
# pip3 install virtualenv
# pip3 install virtualenvwrapper
2. 进入.bashrc文件中,定义virtualenvwrapper路径
使用nano编辑.bashrc文件
# nano ~/.bashrc
在文末填入以下代码并保存
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 # 指定virtualenvwrapper执行的python版本
export WORKON_HOME=$HOME/.virtualenvs # 指定虚拟环境存放目录,.virtualenvs目录名可自拟
source /usr/local/bin/virtualenvwrapper.sh # virtualenvwrapper.sh所在目录
3. 运行.bashrc文件
# source ~/.bashrc
4. 创建虚拟环境
# mkvirtualenv buildIos
也可指定虚拟环境的python版本
mkvirtualenv --python=/usr/bin/python3 buildIos
5. 进入虚拟环境中,然后进入到项目所在目录,安装好相应的包(如无需要,可跳过此步)
# pip install -r requirements.txt
虚拟环境搭建完成!
常见的virtualenvwrapper命令
- 创建虚拟环境
-
# mkvirtualenv my_env
- 切换到某个虚拟环境
-
# workon my_env
- 退出当前虚拟环境
-
# deactivate
- 删除某个虚拟环境
-
# rmvirtualenv my_env
- 列出所有虚拟环境
-
# lsvirtualenv
- 进入到虚拟环境所在的目录
-
# cdvirtualenv
三、异常情况
- 假如source ~/.bashrc时,提示以下错误
-
# source ~/.bashrc >> -bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory
【原因】
.bashrc文件中的virtualenvwrapper.sh所在目录错误。
【解决方案】
①查找virtualenvwrapper.sh所在目录
# find / -name "virtualenvwrapper.sh" >> /usr/local/python3/bin/virtualenvwrapper.sh
②把.bashrc文件的virtualenvwrapper.sh目录更改为实际所在目录
source /usr/local/python3/bin/virtualenvwrapper.sh # virtualenvwrapper.sh实际所在目录
- 假如创建虚拟环境时,提示以下错误
-
# mkvirtualenv my_env >> ERROR: virtualenvwrapper could not find virtualenv in your path
【解决方案】
①查找virtualenv所在目录
# find / -name "virtualenv" >> /usr/local/python3/bin/virtualenv
②创建软链接
# ln -s /usr/local/python3/bin/virtualenv /usr/local/bin/virtualenv
安装ios开发环境
安装xcode
安装ruby
安装pods
gitlab创建测试仓库,仓库中至少存在2个分支
如果要清除仓库中多余的分支请参照:git删除远程分支
新建分支请参照:Git 分支 - 分支的新建
里程碑:
使用命令行打包
-
-
第一步
终端进入.xcworkspace
文件目录
-
cd /Users/5i5j/Desktop/test/HelloWorld
第二步:执行构建脚本:
先简单用3个命令打出,确认命令可以正常执行:
1 echo -e "============First Build Clean============" 2 ## 清理缓存 3 xcodebuild clean -workspace HelloWorld.xcworkspace -scheme HelloWorld -configuration Release 4 5 echo -e "============Build Archive============" 6 ## 导出archive包 7 xcodebuild archive -workspace HelloWorld.xcworkspace -scheme HelloWorld -archivePath build/HelloWorld.xcarchive -configuration Release 8 9 echo -e "============Export IPA============" 10 ## 导出IPA包 11 xcodebuild -exportArchive -archivePath build/HelloWorld.xcarchive -exportPath /Users/5i5j/Desktop/test/build/HelloWorld -exportOptionsPlist /Users/5i5j/Desktop/test/build/ExportOptions.plist
配置参数说明:
打包:
语法:xcodebuild -workspace <.xcworkspace文件全称> -scheme <schemeName> -archivePath <编译成功之后产生的.xcarchive文件存放路径> -configuration <编译环境> archive
编译环境:默认就有Debug
和Release
,当然也有你自己配置的环境
导出ipa包:
语法:xcodebuild -exportArchive -archivePath <.xcarchive文件存放的路径> -exportPath <生成的.ipa包存放的路径> -exportOptionsPlist <.ipa包的配置文件路径>
ExportOptions.plist
文件,我们通过xcode打包时就会生成这个文件,可以直接拿该文件来使用。
遇到的问题及解决办法:
error: exportArchive: You don’t have permission to save the file “HelloWorld.ipa” in the folder “HelloWorld”.
具体参数的含义参照:https://www.jianshu.com/p/6a0aa8cd2e97
使用python脚本将ipa包上传蒲公英
配置jenkins
自定义构建信息
连接git
使用git parameter管理git仓库
使用shell构建测试包
其它:
如果打包报这个错:jenkins打包ios 报错rror: No signing certificate "iOS Distribution" found: No "iOS Distribution...
个性tomcat的开机启动方式为shell启动,试一试,具体方法:Mac开机自动运行shell脚本
Mac如何显示资源库(Library)
Mac中Library目录是默认隐藏的,要想找到此文件夹有如下几种方法:
1.使用terminal
$ chflags nohidden ~/Library
$ chflags hidden ~/Library(隐藏)
2.在Finder菜单中的偏好设置中设置
在Finder菜单中的偏好设置中选择【边栏】,勾选上设备中的【硬盘】。
再打开Finder,Finder的左边栏会有设备显示,在这里可以找到用户下的资源库也可以找到系统下的资源库文件目录了。
想要隐藏,去掉Finder偏好设置中边栏选项设备中的硬盘勾选
或着直接在Finder的左边栏上设备出悬浮鼠标会出现隐藏,直接隐藏即可。
https://www.jianshu.com/p/f3e19a558b0c