安装相关ios插件后,进行新增节点
新建节点
2.输入节点名称,勾选PermanentAgent
系统管理里节点管理
若没有Launch slave agents on Unix machines via SSH选项,需要安装SSH Slaves plugin插件
若没有Keychains and Provisioning Profiles Management选项,需要安装kpp-management-plugin插件
系统设置里还要增加ios 的ssh服务器地址
ios机器上也要安装jenkins,我们来开始安装Jenkins。从官网Jenkins 上下载最新的pkg安装包。
配置IOS节点,同时还要安装X-code插件
同时构建选择X-code构建,刚开始出现错误
xcodebuild xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instanc
解决的办法是:
修改xcode指向的目录
xcode-select -s /Applications/Xcode.app/Contents/Developer
通过上面方式就可以解决上面的错误了
但后面出现签名报错
Code Signing Error: The operation couldn’t be completed. Unable to log in with account /usr/bin/codesign --force --sign A71F659AF2D822167570D824E394C2837B8666A5 --entitlements /Users/bird-air/Library/Developer/Xcode/DerivedData/sgtyanglao-bcztllskcyuxawezxipfblayupnn/Build/Intermediates.noindex/ArchiveIntermediates/sgtyanglao/IntermediateBuildFilesPath/sgtyanglao.build/Release-iphoneos/sgtyanglao.build/卫士.app.xcent --timestamp=none /Users/bird-air/Library/Developer/Xcode/DerivedData/sgtyanglao-bcztllskcyuxawezxipfblayupnn/Build/Intermediates.noindex/ArchiveIntermediates/sgtyanglao/InstallationBuildProductsLocation/Applications/卫士.app /Users/bird-air/Library/Developer/Xcode/DerivedData/sgtyanglao-bcztllskcyuxawezxipfblayupnn/Build/Intermediates.noindex/ArchiveIntermediates/sgtyanglao/InstallationBuildProductsLocation/Applications/卫士.app: errSecInternalComponent Command /usr/bin/codesign failed with exit code 1
一直出现上面的问题,后来在苹果电脑上运行
/usr/bin/codesign --force --sign A71F659AF2D822167570D824E394C2837B8666A5 --entitlements /Users/bird-air/Library/Developer/Xcode/DerivedData/sgtyanglao-bcztllskcyuxawezxipfblayupnn/Build/Intermediates.noindex/ArchiveIntermediates/sgtyanglao/IntermediateBuildFilesPath/sgtyanglao.build/Release-iphoneos/sgtyanglao.build/卫士.app.xcent --timestamp=none /Users/bird-air/Library/Developer/Xcode/DerivedData/sgtyanglao-bcztllskcyuxawezxipfblayupnn/Build/Intermediates.noindex/ArchiveIntermediates/sgtyanglao/InstallationBuildProductsLocation/Applications/卫士.app
出现一个权限问题,授予永久访问,上面的问题就解决了
security unlock-keychain -p "bird" /Users/bird-air/Library/Keychains/login.keychain-db
好像上面也没有什么用
** ARCHIVE SUCCEEDED ** Cleaning up previously generated .ipa files Cleaning up previously generated .dSYM.zip files Packaging IPA [birdcartest] $ /usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleVersion" /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/Info.plist [birdcartest] $ /usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleShortVersionString" /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/Info.plist Packaging sgtyanglao.xcarchive => /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao-7.5-2.1.ipa [birdcartest] $ /usr/bin/xcodebuild -exportArchive -archivePath /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive -exportPath /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos -exportOptionsPlist /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/ad-hocAUTOMATICExportOptions.plist -allowProvisioningUpdates 2019-08-15 10:47:24.203 xcodebuild[16452:127767] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/47/50k_r76j41d7rwh9521q9sy00000gn/T/sgtyanglao_2019-08-15_10-47-24.202.xcdistributionlogs'. 2019-08-15 10:47:24.360 xcodebuild[16452:127790] DVTDeveloperAccountManager: Failed to load credentials for 1712863538@qq.com: Error Domain=DVTSecErrorDomain Code=-25308 "User interaction is not allowed." UserInfo={NSLocalizedDescription=User interaction is not allowed.} 2019-08-15 10:47:26.298 xcodebuild[16452:127790] DVTPortal: Service '' encountered an unexpected result code from the portal ('1100') 2019-08-15 10:47:26.299 xcodebuild[16452:127790] DVTPortal: Error: Error Domain=DVTPortalServiceErrorDomain Code=1100 "Your session has expired. Please log in." UserInfo={payload={type = mutable dict, count = 9, entries =>
后来一直出现上面的问题,不知道怎么解决,应该也是权限问题,后来在ios机器上进行工程的编译,archive操作,同时进行对archive继续export做ipa的时候出现权限问题,我点永久授权后就成功了
Exported sgtyanglao.xcarchive to: /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos ** EXPORT SUCCEEDED ** Archiving dSYM [Release-iphoneos] $ ditto -c -k --keepParent -rsrc /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/dSYMs/卫士.app.dSYM /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao-7.5-2.1-dSYM.zip Finished: SUCCESS
在ios机器上编译好后,应该还要看看发送到jenkins服务器 上,同时上传蒲公英进行测试
我执行下面语句
su jenkins
输入密码后,提示错误
这是由于没有激活jenkins。
之后我执行下面命令:
sudo passwd jenkins
Enter new UNIX password: 输入新密码
Retype new UNIX password:再次输入新密码
passwd: password updated successfully
之后再执行:
su jenkins
因为Jenkins对现在的Xcode9插件兼容性不好,打不了包,所以我们使用了xcodebuild打包,一般要用脚本来打包
但后来还是没有用脚本,没有做成有问题,以后有时间再研究
还是用xcode 插件来打包成功了
同时上传到蒲公英上,在ios机器jenkins上执行新脚本,就相当于增加一个shell
#!/bin/bash export LANG=en_US.UTF-8 # 通过api上传到蒲公英当中 echo "===上传至蒲公英平台===" #Jenkins name jenkins_name="birdcartest" # 蒲公英userkey pgyerUserKey="40bd9ff5f0661d0f3db81632a615a614" # 蒲公英apiKey pgyerApiKey="7664dae3183031b51a27390d83877d63" #WORKSPACE WORKSPACE="/Users/Shared/Jenkins/workspace" #指定项目名 project_name="sgtyanglao" #ipa名称 bundleversion=$(/usr/libexec/PlistBuddy -c "print ApplicationProperties:CFBundleShortVersionString" "$WORKSPACE/$jenkins_name/build/Release-iphoneos/${project_name}.xcarchive/Info.plist") bundlebuild=$(/usr/libexec/PlistBuddy -c "print ApplicationProperties:CFBundleVersion" "$WORKSPACE/$jenkins_name/build/Release-iphoneos/${project_name}.xcarchive/Info.plist") #bundleversion=$(/usr/libexec/PlistBuddy -c 'print ApplicationProperties:CFBundleShortVersionString' "/Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/Info.plist") #bundlebuild=$(/usr/libexec/PlistBuddy -c 'print ApplicationProperties:CFBundleVersion' "/Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/Info.plist") ipa_name=$project_name"-"$bundleversion"-"$bundlebuild".ipa" echo $ipa_name #描述信息 des="上传ios到蒲公英测试" echo "des:+$des" packageTime="打包时间:【`date \"+%Y-%m-%d %H:%M:%S\"`】---" echo $packageTime ipa_path="$WORKSPACE/$jenkins_name/build/Release-iphoneos" echo $ipa_path/$ipa_name if [ -e $ipa_path/$ipa_name ]; then RESULT=$(curl -F "_api_key=$pgyerApiKey" \ -F "file=@$ipa_path/$ipa_name" \ -F "buildInstallType=2" \ -F "buildPassword=1230" \ -F "buildUpdateDescription=$packageTime$des" \ https://www.pgyer.com/apiv2/app/upload) echo $RESULT if [ "$RESULT" ]; then echo "===完成蒲公英平台上传===" else echo "===上传蒲公英平台失败===" fi # open ${ipa_path} else echo "===上传蒲公英平台失败===" fi
参考
echo exportArchive parameters begin ---- echo $JOB_BASE_NAME echo $JOB_NAME build_dir="$WORKSPACE/build" project_name="${PROJECT_NAME}" archivePath="$build_dir/$sgtyanglao.xcarchive" exportPath=$build_dir exportOptionsPlist="$WORKSPACE/ExportOptions_Debug.plist" echo $archivePath echo $exportPath echo $exportOptionsPlist echo exportArchive parameters end ---- security unlock-keychain -p "bird" ~/Library/Keychains/login.keychain-db xcodebuild -exportArchive -archivePath "$archivePath" -exportPath "$exportPath" -exportOptionsPlist "$exportOptionsPlist" -allowProvisioningUpdates #xcodebuild -exportArchive -archivePath /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive -exportPath /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos -exportOptionsPlist /Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/ad-hocAUTOMATICExportOptions.plist -allowProvisioningUpdates
现在编译卫士ios过程记录
后来拿来苹果电脑后,地址改变了,这样系统管理与节点地址都要修改一下了
同时在jenkins服务器上也要重新登录一下新的服务器地址
如ssh bird-air@172.18.81.106
输入密码bird就可以了
下面还是要加入
否则会出现下面错误
/usr/bin/codesign '-r-' '--display' '/Users/bird-air/Library/Developer/Xcode/DerivedData/HBuilder-Hello-dlkdwoyjojjrpcdbpbezjpeyhtom/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/InstallationBuildProductsLocation/Applications/HBuilder.app/Frameworks/libswiftCore.dylib' /Users/bird-air/Library/Developer/Xcode/DerivedData/HBuilder-Hello-dlkdwoyjojjrpcdbpbezjpeyhtom/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/InstallationBuildProductsLocation/Applications/HBuilder.app/Frameworks/libswiftCore.dylib: code object is not signed at all Codesigning /Users/bird-air/Library/Developer/Xcode/DerivedData/HBuilder-Hello-dlkdwoyjojjrpcdbpbezjpeyhtom/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/InstallationBuildProductsLocation/Applications/HBuilder.app/Frameworks/libswiftCore.dylib /usr/bin/codesign '--force' '--sign' 'D197EAC3C082A7D8CB874291FCC5E41448360901' '--verbose' '/Users/bird-air/Library/Developer/Xcode/DerivedData/HBuilder-Hello-dlkdwoyjojjrpcdbpbezjpeyhtom/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/InstallationBuildProductsLocation/Applications/HBuilder.app/Frameworks/libswiftCore.dylib' /Users/bird-air/Library/Developer/Xcode/DerivedData/HBuilder-Hello-dlkdwoyjojjrpcdbpbezjpeyhtom/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/InstallationBuildProductsLocation/Applications/HBuilder.app/Frameworks/libswiftCore.dylib: errSecInternalComponent error: Task failed with exit 1 signal 0 { /usr/bin/codesign '--force' '--sign' 'D197EAC3C082A7D8CB874291FCC5E41448360901' '--verbose' '/Users/bird-air/Library/Developer/Xcode/DerivedData/HBuilder-Hello-dlkdwoyjojjrpcdbpbezjpeyhtom/Build/Intermediates.noindex/ArchiveIntermediates/HBuilder/InstallationBuildProductsLocation/Applications/HBuilder.app/Frameworks/libswiftCore.dylib' } ** ARCHIVE FAILED *
出现上面错误后,配置增加下面就解决
同时因为工程文件不是根目录所以要修改下面
最后, H5 ios编译 上传如下:
#!/bin/bash export LANG=en_US.UTF-8 # 通过api上传到蒲公英当中 echo "===上传至蒲公英平台===" #Jenkins name jenkins_name=$JOB_NAME # 蒲公英userkey pgyerUserKey="40bd9fdae31830316327390d838" # 蒲公英apiKey pgyerApiKey="7664dae3183031b50f3db816323d" #WORKSPACE WORKSPACE=$WORKSPACE #指定项目名 project_name="HBuilder-Hello" #ipa名称 bundleversion=$(/usr/libexec/PlistBuddy -c "print ApplicationProperties:CFBundleShortVersionString" "$WORKSPACE/${project_name}/build/Release-iphoneos/HBuilder.xcarchive/Info.plist") bundlebuild=$(/usr/libexec/PlistBuddy -c "print ApplicationProperties:CFBundleVersion" "$WORKSPACE/${project_name}/build/Release-iphoneos/HBuilder.xcarchive/Info.plist") #bundleversion=$(/usr/libexec/PlistBuddy -c 'print ApplicationProperties:CFBundleShortVersionString' "/Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/Info.plist") #bundlebuild=$(/usr/libexec/PlistBuddy -c 'print ApplicationProperties:CFBundleVersion' "/Users/Shared/Jenkins/workspace/birdcartest/build/Release-iphoneos/sgtyanglao.xcarchive/Info.plist") ipa_name="HBuilder-"$bundleversion"-"$bundlebuild".ipa" echo $ipa_name #描述信息 des="上传ios到蒲公英测试" echo "des:+$des" packageTime="打包时间:【`date \"+%Y-%m-%d %H:%M:%S\"`】---" echo $packageTime ipa_path="$WORKSPACE/${project_name}/build/Release-iphoneos" echo $ipa_path/$ipa_name if [ -e $ipa_path/$ipa_name ]; then RESULT=$(curl -F "_api_key=$pgyerApiKey" \ -F "file=@$ipa_path/$ipa_name" \ -F "buildInstallType=2" \ -F "buildPassword=1230" \ -F "buildUpdateDescription=$packageTime$des" \ https://www.pgyer.com/apiv2/app/upload) echo $RESULT if [ "$RESULT" ]; then echo "===完成蒲公英平台上传===" else echo "===上传蒲公英平台失败===" fi # open ${ipa_path} else echo "===上传蒲公英平台失败===" fi
附件:
原生在apple电脑上打包与编译
开始是要进行build build 后要选中真机或Generic IOS Device 可以Achive 在进行export出IPA文件
有时候客户端IOS地址换过后,好像ios工程要重新编译过,jenkins才可以通过,可能也是授权问题吧
奉化苹果电脑,编译医院管理软件时出现下面问题
PhaseScriptExecution [CP]\ Copy\ Pods\ Resources /Users/bird-air/Library/Developer/Xcode/DerivedData/ChanghaiHospital-biztxwfnegonmtayiflvfrydqzxn/Build/Intermediates.noindex/ArchiveIntermediates/ChanghaiHospital/IntermediateBuildFilesPath/ChanghaiHospital.build/Release-iphoneos/ChanghaiHospital.build/Script-D39C92536783404A4887B8FA.sh cd /Users/Shared/Jenkins/workspace/hospital-manageAppIOS /bin/sh -c /Users/bird-air/Library/Developer/Xcode/DerivedData/ChanghaiHospital-biztxwfnegonmtayiflvfrydqzxn/Build/Intermediates.noindex/ArchiveIntermediates/ChanghaiHospital/IntermediateBuildFilesPath/ChanghaiHospital.build/Release-iphoneos/ChanghaiHospital.build/Script-D39C92536783404A4887B8FA.sh /Users/bird-air/Library/Developer/Xcode/DerivedData/ChanghaiHospital-biztxwfnegonmtayiflvfrydqzxn/Build/Intermediates.noindex/ArchiveIntermediates/ChanghaiHospital/IntermediateBuildFilesPath/ChanghaiHospital.build/Release-iphoneos/ChanghaiHospital.build/Script-D39C92536783404A4887B8FA.sh: line 2: /Users/Shared/Jenkins/workspace/hospital-manageAppIOS/Pods/Target Support Files/Pods-ChanghaiHospital/Pods-ChanghaiHospital-resources.sh: Permission denied ** ARCHIVE FAILED ** The following build commands failed: PhaseScriptExecution [CP]\ Copy\ Pods\ Resources /Users/bird-air/Library/Developer/Xcode/DerivedData/ChanghaiHospital-biztxwfnegonmtayiflvfrydqzxn/Build/Intermediates.noindex/ArchiveIntermediates/ChanghaiHospital/IntermediateBuildFilesPath/ChanghaiHospital.build/Release-iphoneos/ChanghaiHospital.build/Script-D39C92536783404A4887B8FA.sh (1 failure) Build step 'Xcode' marked build as failure Finished: FAILURE
应该还是工程文件里的权限问题,就是/Users/Shared/Jenkins/workspace/hospital-manageAppIOS/Pods/Target Support Files/Pods-ChanghaiHospital/Pods-ChanghaiHospital-resources.sh:
这个文件权限不够,应该对workespace都要进行一个 chmod -R 774 workspace/
#!/bin/bash -l export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 export LC_ALL=en_US.UTF-8 pwd pod install --verbose --no-repo-update pwd chmod -R 774 *
在上面shell里执行,因为是动态的
下载安装pod后进行权限调整
医院项目默认就是下面目录下,所以上面的pwd就是下面