Jenkins on macOS

通过Homebrew

需注意的是,最新的Jenkins需要Java8的环境。

直接brew安装:

yul@MAC-LUOYU > brew install jenkins
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (caskroom/cask).
No changes to formulae.

==> Using the sandbox
==> Downloading http://mirrors.jenkins-ci.org/war/2.70/jenkins.war
==> Downloading from http://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.70/jenkins.war
######################################################################## 100.0%
==> jar xvf jenkins.war
==> Caveats
Note: When using launchctl the port will be 8080.

To have launchd start jenkins now and restart at login:
  brew services start jenkins
Or, if you don't want/need a background service you can just run:
  jenkins
==> Summary
?  /usr/local/Cellar/jenkins/2.70: 7 files, 72.2MB, built in 1 minute 48 seconds

快速又便捷,并给出使用的提示,

如果想启动Jenkins并且让它重启登录时自启动,使用命令:

brew services start jenkins

或如果你不想让它作为后台服务运行,可以直接使用命令:

jenkins

按照上面的提示开启Homebrew服务,并设置Jenkins随系统启动的服务:

 yul@MAC-LUOYU > brew services start jenkins
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 12 (delta 0), reused 7 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), done.
Tapped 0 formulae (40 files, 53.8KB)
==> Successfully started `jenkins` (label: homebrew.mxcl.jenkins)

配置

Jenkins启动后,默认端口号是8080,

可以直接访问例如本机http://localhost:8080

会显示首次登录的Unlock Jenkins页面

这里会要求一个初始的管理员密码验证,并告知了该密码在服务器上的位置,

所以可以:

cat ~/.jenkins/secrets/initialAdminPassword

安装的过程也很简介,有推荐的插件可以直接开启Jenkins,也可以手选自己需要的插件。

等待各个插件的安装完成..

最后会提示创建一个admin管理员账号:

Xcode Objective-C Swift混合项目的小问题

Xcode Objective-C Swift混合项目的小问题

向Objective-C工程中添加Swift

  1. 在Xcode中创建一个*.swift文件

    在Xcode弹出提示时,选择创建一个Objective-C Bridging Header文件

    如果未选择创建,可以手动创建该头文件,并在Build Settings里增加配置Objective-C Bridging Header -> $(SRCROOT)/projectname-Bridging-Header.h

  2. 实现Swift类

    类使用@objc注解

  3. Build Settings的参数检查

    • define module = YES
    • Product Module Name = projectname (不可以有特殊字符)
    • Install Objective-C Compatibility Header = YES
    • Objective-C Bridging Header
  4. 在要用到Swift类的ObjC的实现文件.m内,导入Swift接口的头文件

#import "projectname-Swift.h"

Author

Luo Yu

Friday, July 7, 2017