7

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)
cesarislaw
  • 1,589
  • 1
  • 11
  • 21

2 Answers2

5

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

malenkiy_scot
  • 16,415
  • 6
  • 64
  • 87
  • Could you describe what the "right" permissions are/look like? xcodebuild has 755 which I would think would let any user execute the program from any directory. The project directory also has 755 permissions. The Jenkins user is the daemon user. – cesarislaw Mar 21 '12 at 14:11
  • What I actually meant is that you should run Jenkins with the user that owns the directory. Alternatively, make it writable. – malenkiy_scot Mar 21 '12 at 14:51
  • I've tried both at various points. Checked again (set directory permissions to 775 and ownership to the daemon user) and still getting the permission denied error. – cesarislaw Mar 21 '12 at 15:35
  • What happens if you su to the user that jenkins is running as (I believe it's daemon by default) and then trying xcodebuild there? – teamaxe Mar 21 '12 at 15:42
  • @teamaxe I think you're on to something. I've added the output of sudo -u daemon xcodebuild to the question. – cesarislaw Mar 21 '12 at 16:11
  • 2
    So what about the permissions up the directory path `/Users/iosappdev` etc.? – malenkiy_scot Mar 21 '12 at 18:05
  • @malenkiy_scot That's it. One of the upstream directories is 700, chmoding to 701 resolved the issue. Thanks guys! – cesarislaw Mar 21 '12 at 18:27
  • @cesarislaw - I have given *read & write permission* for *everyone* in my project yet I get the same issue. – Durai Amuthan.H Mar 22 '16 at 10:56
  • @malenkiy_scot - I am also facing the similar problem.For me the user.name is *jenkins* ... I have not specifically given permission ....I have given *read & write permission* for *everyone* But I am still facing the problem..any ideas on how to solve it – Durai Amuthan.H Mar 22 '16 at 10:58
0

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.

sti
  • 11,047
  • 1
  • 27
  • 27
  • A bit late for a comment but... I'm experiencing the same thing. I think the reason is that the xcode plugin allows you to specify an "Xcode Project Directory" and it's changing the working directory to that. I'm running 1.512 on OSX and jenkins is running as user "jenkins", so I don't think it has permission to access files under my user directory just like the OP. Is there a way to get jenkins to work under these constraints? I'd rather not have to set up VC to just run a jenkins build. It should be possible to use jenkins for builds without a VC system. – Tony Apr 25 '13 at 06:14