Jenkins Can't Run xcodebuild from project folder

断了今生、忘了曾经 提交于 2019-12-21 11:32:08

问题


I'm attempting to set up a CI environment for an iOS application. So far I've gotten xcodebuild to build the test build correctly from the command line but when Jenkins tries to execute it I get the following read out in the console:

Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/Unit Tests/workspace
Working directory is /Users/iosappdev/Documents/Xcode Projects/rules.
[rules] $ /usr/bin/xcodebuild -version
FATAL: Cannot run program "/usr/bin/xcodebuild" (in directory "/Users/iosappdev/Documents/Xcode Projects/rules"): error=13, Permission denied
java.io.IOException: Cannot run program "/usr/bin/xcodebuild" (in directory "/Users/iosappdev/Documents/Xcode Projects/rules"): error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:707)
    at hudson.Launcher$ProcStarter.start(Launcher.java:338)
    at hudson.Launcher$ProcStarter.join(Launcher.java:345)
    at au.com.rayh.XCodeBuilder.perform(XCodeBuilder.java:224)

Any thoughts? I'm fairly new to Jenkins but I have done my best to answer this question with Google Fu to no avail. I did originally run into this problem with a manual installation of Jenkins (homebrew technically) but recently used the OSX installer and it resulted in the same error.

I'm guessing this has more to do with Unix/Linux/OSX permissions than Jenkins/Xcode but don't have enough expertise to determine that for certain.

Edit

Project directory permissions set to 775.

I've also tried changing the ownership to the user Jenkins runs on.

Here's the output for when I attempted to run xcodebuild as the daemon user ($ sudo -u daemon xcodebuild):

dev-imac:rules iosappdev$ sudo -u daemon xcodebuild
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
2012-03-21 11:05:46.161 xcodebuild[1411:70b] [MT] DVTAssertions: ASSERTION FAILURE in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-1196/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/Xcode3Model/Xcode3Project.m:266
Details:  Assertion failed: [directoryPath isAbsolutePath]
Object:   <Xcode3Project>
Method:   +projectFilesInDirectory:
Thread:   <NSThread: 0x40010a260>{name = (null), num = 1}
Hints: None
Backtrace:
  0  0x000000010025b85f -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DVTFoundation)
  1  0x000000010025b6b5 _DVTAssertionFailureHandler (in DVTFoundation)
  2  0x00000001011559bc +[Xcode3Project projectFilesInDirectory:] (in DevToolsCore)
  3  0x00000001008a424b -[Xcode3CommandLineBuildTool _resolveInputOptions] (in Xcode3Core)
  4  0x00000001008aa097 -[Xcode3CommandLineBuildTool run] (in Xcode3Core)
  5  0x00000001001d7db6 (in xcodebuild)
  6  0x00000001001d7c2c (in xcodebuild)

回答1:


Make sure that the user under which Jenkins runs has the right permissions. Go to http://[jenkins_server]/systemInfo and search for user.name.




回答2:


Above it reads:

Building in workspace /Users/Shared/Jenkins/Home/jobs/Unit Tests/workspace Working directory is /Users/iosappdev/Documents/Xcode Projects/rules. [rules] $ /usr/bin/xcodebuild -version

Somehow the job execution has jumped into a "wrong" directory. Maybe you have set the job with a custom workspace? Jenkins is probably running as user daemon and thus has no access to files under the user iosappdev.

The usual way to use Jenkins is for you to commit your source code to a version control repository. Jenkins jobs are then configured to check out the code from the repository into the Jenkins workspace and build it there and then report back the results.

I'm not sure what can be achieved by trying to make Jenkins jump directly into your working directory and do the build there. If that is really what you are trying to do, you need to tell us why you think it is a good idea.



来源:https://stackoverflow.com/questions/9795410/jenkins-cant-run-xcodebuild-from-project-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!