配置Jenkins

0.jenkins的原理html

將代碼託管到服務器,jenkins執行build以前須要去服務器(git or svn)拉取最新的代碼到本地,參考目錄爲 /Users/admin/.jenkins/workspacejava

1.安裝java jdkgit

因爲Jenkins目前只支持Java8-11,因此不能安裝Java12xcode

能夠到官網下載https://www.oracle.com/technetwork/java/javase/downloads/index.htmlbash

也能夠使用brew 安裝服務器

brew cask install java11

2.安裝Jenkinsoracle

brew install jenkins

推薦使用brew安裝Jenkins,若是使用官網的pkg包安裝,會出現各類蛋疼的權限問題app

⚠️:安裝成功後,須要記錄admin的初始密碼iphone

3.執行war包svn

java -jar /usr/local/Cellar/jenkins/版本號/libexec/jenkins.war --httpPort=8080

當命令行中提示「Jenkins is fully up and running」即表示執行成功,能夠進行下一步的操做

安裝以後先不要打開localhost:8080

4.open /Library/LaunchDaemons

open /Library/LaunchDaemons

在裏面新建一個文件org.jenkins-ci.plist,其的內容爲

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>StandardOutPath</key>
    <string>/var/log/jenkins/jenkins.log</string>
    <key>StandardErrorPath</key>
    <string>/var/log/jenkins/jenkins.log</string>
    <key>EnvironmentVariables</key>
    <dict>
      <key>JENKINS_HOME</key>
      <string>/Users/admin/Documents/Jenkins/Home</string>
    </dict>
    <key>GroupName</key>
    <string>daemon</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.jenkins-ci</string>
    <key>ProgramArguments</key>
    <array>
      <string>/bin/bash</string>
      <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>jenkins</string>
    <key>SessionCreate</key>
    <true/>
  </dict>
</plist>

5.啓動Jenkins 

sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

這裏可能會遇到Path had bad ownership/permissions權限問題,執行

sudo chown root:wheel /Library/LaunchDaemons/org.jenkins-ci.plist

而後重複執行上邊 啓動jenkins 的命令

6.網頁中打開localhost:8080,就能夠正常操做了,附上一個jenkins的打包腳本

xcodebuild -archivePath "/Users/admin/Desktop/未命名文件夾/JenkinsApp/build/archive/JenkinsApp.xcarchive"  -sdk iphoneos -scheme "JenkinsApp" -configuration "Release" archive
 
xcodebuild -exportArchive -archivePath "/Users/admin/Desktop/未命名文件夾/JenkinsApp/build/archive/JenkinsApp.xcarchive" -exportPath "/Users/admin/Desktop/未命名文件夾/JenkinsApp/build/ipa" -exportOptionsPlist '/Users/admin/Desktop/未命名文件夾/JenkinsApp/ExportOptions.plist' -allowProvisioningUpdates

 

 

參考連接:

mac下Jenkins 主目錄致使的權限問題(參考jenkins環境配置) https://www.jianshu.com/p/dc6f3fea7aa9

Jenkins在MAC上搭建CI(持續化集成)終結版(參考Jenkins的使用) https://www.jianshu.com/p/d76c9fd8dac5

修改插件的source地址https://blog.csdn.net/you227/article/details/81076032

fastlane+jenkins https://www.jianshu.com/p/3b4a131653e0

相關文章
相關標籤/搜索