美文网首页Jinkens
jenkins+cocoapod+SVN+xcode8+bugl

jenkins+cocoapod+SVN+xcode8+bugl

作者: 佐筱猪 | 来源:发表于2016-11-18 10:55 被阅读247次

    安装Jenkins

    方法一:安装包http://jenkins-ci.org


    此处需注意,否者会有权限等问题(如果不勾选 编译的时候会报LSOpenURLsWithRole() failed with error -10810)
    安装成功后,启动会让你去路径下找密码,按照输入就好

    启动
    open /Applications/Jenkins/jenkins.war
    
    卸载
    sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist  
    sudo rm !$  
    sudo rm -rf /Applications/Jenkins "/Library/Application Support/Jenkins" /Library/Documentation/Jenkins  
    sudo rm -rf /Users/Shared/Jenkins  
    # if you want to get rid of all the jobs and builds:  
    sudo dscl . -delete /Users/jenkins  
    # delete the jenkins user and group (if you chose to use them):  
    sudo dscl . -delete /Groups/jenkins 
    

    方法二:命令

    安装
    brew install jenkins
    
    启动
    jenkins
    
    卸载
    brew uninstall Jenkins
    
    brew无效? 哦 安装homebrew
    $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    
    端口号冲突
    sudo defaults write /Library/Preferences/org.jenkins-ci httpPort 7070
    
    启动路径
    http://localhost:8080/
    

    安装插件

    在系统管理 -> 插件管理中添加如下插件

    Xcode integration
    Subversion Plug-in
    

    新建一个项目

    1. 点击左侧工具栏”新建”,选择第一项”构建一个自由风格的软件项目”
    2. 基本信息
    3. 参数化构建过程

      由于项目中需要多个网络环境(我们公司需要内网外网环境),因此加入bool参数
    4. SVN配置


    5. 构建
      构建=>增加构建步骤=>Execute shell
    pod update --no-repo-update   (可选)
    

    适配坑王XMPP,由于系统和XMPP框架同时用到了 'dnssd',大概就是错误的原因。因此需要pod xmpp3.7的库

    pod 'XMPPFramework', :git => "https://github.com/robbiehanson/XMPPFramework.git", :branch => 'master'
    

    当你引用好3.7的库以后,使用jenkins编译又开始频繁报错,找不到头文件,那么添加srcroot


    xcode编译报错,大致意思是又跟系统同时用到了相通的枚举类型
    重新pod更新。。。
    修改XMPPStream.h的头文件
    CocoaAsyncSocket/GCDAsyncSocket.h=>GCDAsyncSocket.h
    终于通过编译,果然坑多,为了怕吓到后来人(毕竟22个错误),决定将以上步骤改成脚本来执行。
    首先依然添加srcroot,在删除,提交到svn。(为了方便执行脚本,添加在删除后,会新增USER_HEADER_SEARCH_PATHS = "",方便查找替换)
    在Execute shell中加入如下代码
    cd xxxxx.xcodeproj
    sed 's#USER_HEADER_SEARCH_PATHS = ""#USER_HEADER_SEARCH_PATHS = "${SRCROOT}/**"#g' project.pbxproj > project.pbxproj.temp
    mv project.pbxproj.temp project.pbxproj
    cd ..
    cd Pods/XMPPFramework/Core/
    chmod 777 XMPPStream.h
    sed 's#CocoaAsyncSocket/GCDAsyncSocket.h#GCDAsyncSocket.h#g' XMPPStream.h > XMPPStream.h.temp
    mv XMPPStream.h.temp XMPPStream.h
    

    编译,ok
    接下来多网络环境,继续添加(因为我们请求地址卸载plist中。。。。)

    cd $WORKSPACE/xxxxx/core/network
    if $NetworkEnvironment 
    then
    cp ServerInfo1.plist ServerInfo.plist
    else
    cp ServerInfo2.plist ServerInfo.plist
    fi
    

    构建=>增加构建步骤=>Xcode(注意顺序,如果反了,可以拖拽调整)
    jenkins本质应该是用xcodebuild进行编译(xctool在xcode8下不好用,好像11月已经更新 还未尝试)。简单说个命令
    查看Targets和Schemes

    xcodebuild -list
    



    1. 上传bugly
      最后在添加一个Execute shell
    #进入ipa路径
    cd ./build
    #压缩上传
    zip -r project.ipa *
    curl —insecure -F "file=@project.ipa" -F "app_id=你的appid" -F "pid=2" -F "title=iOS测试" -F "description=内部测试,请勿外泄" -F "secret=1"  -F "download_limit=1000" https://api.bugly.qq.com/beta/apiv1/exp?app_key=你的appkey
    

    参数解释

    curl -F "file=@demo.ipa" -F "uKey=自己的key" -F "_api_key=自己的key
    secret int 公开范围(1:所有人,2:密码,4管理员,5QQ群,6白名单,默认公开所有人)
    password String 密码(如果公开范围是”密码”需设置)
    users String 如果公开范围是”QQ群”填QQ群号;如果公开范围是”白名单”填QQ号码,并使用;切分开,5000个以内。其他场景无需设置

    替换的url

    curl --insecure -X "PUT" -F "file=@project.ipa" -F "exp_id= df15dfda-324b-4361-92f9-6b56e964fd3e" -F "title=iOS测试" -F "description=内部测试,请勿外泄" -F "secret=1" -F "password=xxxx" -F "users=xxxx" -F "download_limit=1000" https://api.bugly.qq.com/beta/apiv1/exp?app_key=xxxx
    

    bugly上传文档API

    参考

    jenkinsiOS项目持续集成(SVN+Cocoapods+Workspace)实战扩展(修改版)
    Jenkins+GitHub+Xcode+fir搭了一个持续集成环境
    使用Bugly+Jenkins+Xcode实现自动打包分发测试 iOS

    未来

    会加入邮件发送
    相关集成测试、单元测试

    相关文章

      网友评论

      本文标题:jenkins+cocoapod+SVN+xcode8+bugl

      本文链接:https://www.haomeiwen.com/subject/eypjpttx.html