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)
Make sure that the user under which Jenkins runs has the right permissions. Go to http://[jenkins_server]/systemInfo and search for user.name.
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.
Related
Repo with full code example.
When I try to run a test with Bazel involving the tree-sitter binary, I get an Operation not permitted error without any further information.
❯ bazel test --test_output=errors --verbose_failures --sandbox_debug //tree-sitter-nbts:check-generated
INFO: Analyzed target //tree-sitter-nbts:check-generated (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
FAIL: //tree-sitter-nbts:check-generated (see /private/var/tmp/_bazel_varun/e55142ab9bc72292b8c54fb9627025eb/execroot/__main__/bazel-out/darwin_arm64-fastbuild/testlogs/tree-sitter-nbts/check-generated/test.log)
INFO: From Testing //tree-sitter-nbts:check-generated:
==================== Test output for //tree-sitter-nbts:check-generated:
++ dirname /private/var/tmp/_bazel_varun/e55142ab9bc72292b8c54fb9627025eb/sandbox/darwin-sandbox/17/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/tree-sitter-nbts/check-generated.runfiles/__main__/tree-sitter-nbts/check-generated
+ cd /private/var/tmp/_bazel_varun/e55142ab9bc72292b8c54fb9627025eb/sandbox/darwin-sandbox/17/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/tree-sitter-nbts/check-generated.runfiles/__main__/tree-sitter-nbts
+ git init -b main
Initialized empty Git repository in /private/var/tmp/_bazel_varun/e55142ab9bc72292b8c54fb9627025eb/sandbox/darwin-sandbox/17/execroot/__main__/bazel-out/darwin_arm64-fastbuild/bin/tree-sitter-nbts/check-generated.runfiles/__main__/tree-sitter-nbts/.git/
+ git add .
+ GIT_AUTHOR_EMAIL=_
+ GIT_AUTHOR_NAME=_
+ GIT_COMMITTER_EMAIL=_
+ GIT_COMMITTER_NAME=_
+ git commit -m 'Initial commit'
[main (root-commit) 1f79ef2] Initial commit
11 files changed, 11 insertions(+)
create mode 120000 Cargo.lock
create mode 120000 Cargo.toml
create mode 120000 bindings/rust/build.rs
create mode 120000 bindings/rust/lib.rs
create mode 120000 check-generated
create mode 120000 check-generated.sh
create mode 120000 grammar.js
create mode 120000 src/grammar.json
create mode 120000 src/node-types.json
create mode 120000 src/parser.c
create mode 120000 src/tree_sitter/parser.h
+ tree-sitter generate
Operation not permitted (os error 1)
================================================================================
Target //tree-sitter-nbts:check-generated up-to-date:
bazel-bin/tree-sitter-nbts/check-generated
INFO: Elapsed time: 0.220s, Critical Path: 0.11s
INFO: 2 processes: 2 darwin-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//tree-sitter-nbts:check-generated FAILED in 0.1s
/private/var/tmp/_bazel_varun/e55142ab9bc72292b8c54fb9627025eb/execroot/__main__/bazel-out/darwin_arm64-fastbuild/testlogs/tree-sitter-nbts/check-generated/test.log
INFO: Build completed, 1 test FAILED, 2 total actions
What is a good way of debugging this? So far, I know the following:
Running tree-sitter generate directly in the source tree works fine.
The bazel test command works fine with --spawn_strategy=standalone, which I think confirms that this is a sandboxing issue.
The bazel test command works fine inside the Nix environment (see the linked repo). This one is a little weird, not sure what's going on here.
Configuration information:
macOS 12.4 on an M1 Mac
Bazel v5.2.0 (both in Nix and outside)
tree-sitter v0.20.6 (both in Nix and outside) (I tried using the Nix-installed binary with Bazel and that didn't seem to make any difference)
OpenJDK v11.0.15 in the global environment vs OpenJDK v11.0.11 in Nix.
GitHub issues which seem related:
ln call fails with "operation not permitted" during bazel test - This comment mentions there is no command printed with --verbose_failures --sandbox_debug.
Strange "Operation not permitted" problem for test program accessing files in the sand box on MacOS
I am consistently seeing an error when I try to execute bazel run //src:devserver in the angular-bazel-example project.
I am using Windows 10. I haven't been able to find anything that fixes this. I thought the issue might be related to patch or to the path being too long. However, I've used MSYS2 to install patch, I've changed the output directory using the option --output_user_root, and I've tried using a DOS prompt with admin privileges. Nothing seems to help.
The error message
INFO: SHA256 (https://codeload.github.com/golang/tools/zip/3e7aa9e59977626dc60433e9aeadf1bb63d28295) = 2384fa91351a7414b643c5230422ce45f5aa2be8a82727609afd4e64e6973a30
ERROR: Analysis of target '//src:devserver' failed; build aborted: no such package '#org_golang_x_tools//go/gcexportdata': Traceback (most recent call last):
File "C:/temp/vvsv3266/external/bazel_tools/tools/build_defs/repo/http.bzl", line 55
patch(ctx)
File "C:/temp/vvsv3266/external/bazel_tools/tools/build_defs/repo/utils.bzl", line 82, in patch
fail(("Error applying patch %s:\n%s%s...)))
Error applying patch #io_bazel_rules_go//third_party:org_golang_x_tools-gazelle.patch:
java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(383): CreateProcessW("C:\msys64\usr\bin" -c "patch '-p1' < C:/temp/vvsv3266/external/io_bazel_rules_go/third_party/org_golang_x_tools-gazelle.patch"): Access is denied.
INFO: Elapsed time: 691.367s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (484 packages loaded, 20777 targets configured)
FAILED: Build did NOT complete successfully (484 packages loaded, 20777 targets configured)
Fetching #ngdeps; fetching 245s
Fetching #org_golang_x_tools; Patching repository 15s
Can someone please tell me how to remedy this?
My build script includes
make clean
make all
make invokes gcc:
gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
my post-build step is to, "scan for compiler warnings" and I chose the parser for GNU C Compiler 4 (gcc).
Is that enough? Did I miss anything?
My console log shows
[WARNINGS] Parsing warnings in console log with parser GNU C Compiler 4 (gcc)
[WARNINGS] Computing warning deltas based on reference build #72
When I click on the compiler warnings chart and drill down to a single source file, I get
Copying the source file '../software_under_test/maths.c' from the workspace to the build folder '8410a4f3.tmp' on the Jenkins master failed.
02 Seems that the path is relative, however an absolute path is required when copying the sources.
03 Is the file 'maths.c' contained more than once in your workspace?
04 Is the file '../software_under_test/maths.c' a valid filename?
05 If you are building on a slave: please check if the file is accessible under '$JENKINS_HOME/[job-name]/../software_under_test/maths.c'
06 If you are building on the master: please check if the file is accessible under '$JENKINS_HOME/[job-name]/workspace/../software_under_test/maths.c'
07 java.io.IOException: Failed to copy ../software_under_test/maths.c to /home/mawg/.jenkins/jobs/plain_C_project/builds/73/workspace-files/8410a4f3.tmp
08 at hudson.FilePath.copyTo(FilePath.java:1991)
09 at hudson.plugins.analysis.util.Files.copyFilesWithAnnotationsToBuildFolder(Files.java:80)
10 at hudson.plugins.analysis.core.HealthAwareRecorder.copyFilesWithAnnotationsToBuildFolder(HealthAwareRecorder.java:312)
11 at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:89)
12 at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:259)
13 at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:75)
14 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
15 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
16 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
17 at hudson.model.Build$BuildExecution.post2(Build.java:185)
18 at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
19 at hudson.model.Run.execute(Run.java:1766)
20 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
21 at hudson.model.ResourceController.execute(ResourceController.java:98)
22 at hudson.model.Executor.run(Executor.java:408)
23 Caused by: java.io.FileNotFoundException: ../software_under_test/maths.c (No such file or directory)
24 at java.io.FileInputStream.open(Native Method)
25 at java.io.FileInputStream.<init>(FileInputStream.java:146)
26 at hudson.FilePath$41.invoke(FilePath.java:2017)
27 at hudson.FilePath$41.invoke(FilePath.java:2012)
28 at hudson.FilePath.act(FilePath.java:991)
29 at hudson.FilePath.act(FilePath.java:969)
30 at hudson.FilePath.copyTo(FilePath.java:2012)
31 at hudson.FilePath.copyTo(FilePath.java:1986)
32 ... 14 more
What am I doing wrong?
This page says that the code is looking for the string "Entering directory" in the build output and the code verifies this.
I tweaked my make step to output that by adding the --print-directory to the make command and got
+ make all --print-directory
make: Entering directory `/home/mawg/workspace/unit_test_C_code_example_project/Debug'
Building file: ../test_scripts/test_maths.c
Invoking: GCC C Compiler
gcc -DUNIT_TEST -I"/home/mawg/workspace/unit_test_C_code_example_project/mocks" -I"/home/mawg/workspace/unit_test_C_code_example_project/software_under_test" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test_scripts/test_maths.d" -MT"test_scripts/test_maths.d" -o "test_scripts/test_maths.o" "../test_scripts/test_maths.c"
Finished building: ../test_scripts/test_maths.c
etc, but that did not help.
So, can anyone tell me how to configure things so that I an drill down into the source code from the Jenkins compiler warnings plugin?
This was one of the first results when I had this problem, but I have since found that as of at least 2018-07 there is an advanced setting to “Resolve relative paths” (not sure when this was added), but this solved the same problem for me
Update:
After adding the Scan for compiler warnings Post Build action in Jenkins, there will be an Advanced button.
After clicking Advanced a list of options appears. Some way down this list there is a section titled Resolve relative paths, clicking on this solved my problem.
This was in the Warning plugin version 4.66
Solved!
I had the same Problem and got rid of it after following changes:
I set the at the Source Code Management-->Local module Directory
a Period following the checkout Folder of the Project i.e. "./project1"
I didnt have the "./" before.
I added also to the make command the Option --print-directory.
Now it works as expected!
Ok, solved!
The problem was that the makefile generated by Eclipse contain ed a relative path. Relative to the makefile directory that it, but the Jenkins compiler warning plugin was treating it as relative to the Jenkins workspace.
The solution is to edit the makeilfe. Do it once for a manually created makefile. If you use Eclipse it constantly regenerates the makefiles, so the trick is to edit the Jenkins shell script to change the makefile on the fly, immediately prior to building.
Note that I only changed the makefile for the Software Under Test directory. I am not interested in compiler warnings in Google Test, etc
So, now my Jenkins shell script starts
cd /home/mawg/workspace/unit_test_C_code_example_project/Debug
# Tweak the makefile to use an absolute path to the Software Under Test.
# If we use a relative path then the Jenkins comiler wanrings plugin
# cannot find the source code to display it, so that we can drill down
# into it and see the compiler warnings in situ.
sed 's|\.\./software_under_test/maths.c|/home/mawg/workspace/unit_test_C_code_example_project/software_under_test/maths.c|g' /home/mawg/workspace/unit_test_C_code_example_project/Debug/software_under_test/subdir.mk > /home/mawg/workspace/unit_test_C_code_example_project/Debug/software_under_test/subdir.mk.absolute
rm software_under_test/subdir.mk
mv software_under_test/subdir.mk.absolute software_under_test/subdir.mk
make clean
# The --print-directory option is required for the compiler warning plugin
make all --print-directory
I've been building (from a mac terminal) this native application successfully for a long time but today I've run across an error I can't seem to pin down. After tiring from all the javac warnings I upgraded to a newer version of ant. I'm not sure it is related but the timing is suspect. I can still build, deploy, and run my application but now I can no longer use ndk-gdb to debug the native part of the application. It appears on inspection that the gdb.setup file is not getting added to the debug apk.
here is the build sequence, abbreviated output, and information. I'm looking for suggestions on how to resolve the issue.
I've done a full clean on both NDK and ant builds
The android NDK version and android SDK versions are all up to date.
I use the built in ndk-bundle that gets loaded with the android studio sdk tools.
The devices we develop on are not rooted and is not an option.
hsmith$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
hsmith$ $ANT_HOME
-bash: /Users/hsmith/dk/ant/apache-ant-1.9.6: is a directory
hsmith$ ndk-build -j4 NDK_DEBUG=1
[armebi-v7a] Gdbserver : [arm-linux-androideabi-4.8] libs//gdbserver
[armebi-v7a] Gdbsetup : libs//gdb.setup
[armebi-v7a] Install : lib1.so => libs/armebi-v7a/lib1.so
[armebi-v7a] Install : lib2.so => libs/armebi-v7a/lib2.so
[armebi-v7a] Install : lib3.so => libs/armebi-v7a/lib3.so
hsmith$ ant debug
…
-package:
[apkbuilder] Found modified input file
[apkbuilder] Creating -debug-unaligned.apk and signing it with a debug key...
-post-package:
-do-debug:
[zipalign] Running zip align on final apk...
[echo] Debug Package: /Users/hsmith/packageFolder/bin/<package>-debug.apk
[propertyfile] Updating property file: /Users/hsmith/packageFolder/bin/build.prop
[propertyfile] Updating property file: /Users/hsmith/packageFolder/bin/build.prop
[propertyfile] Updating property file: /Users/hsmith/packageFolder/bin/build.prop
[propertyfile] Updating property file: /Users/hsmith/packageFolder/bin/build.prop
-post-build:
debug:
BUILD SUCCESSFUL
hsmith$ adb install -r ~/packageFolder/bin/-debug.apk
hsmith$ ndk-gdb adb --start
ERROR: Package is not debuggable ! You can fix that in two ways:
Rebuilt with the NDK_DEBUG=1 option when calling 'ndk-build'.
Modify your manifest to set android:debuggable attribute to "true",
then rebuild normally.
After one of these, re-install to the device!
I unzipped the apk file to find
unziped apk file/lib/target/
hsmith$ ls -la
total 48264
drwxr-xr-x 12 hsmith staff 408 Aug 25 14:50 .
drwxr-xr-x 5 hsmith staff 170 Aug 25 14:50 ..
-rwxr-xr-x 1 hsmith staff 409940 Jun 3 11:47 gdbserver
-rwxr-xr-x 1 hsmith staff 33920 Aug 25 14:44 lib1.so
-rwxr-xr-x 1 hsmith staff 165092 Aug 25 14:44 lib2.so
-rwxr-xr-x 1 hsmith staff 1614028 Aug 25 14:44 lib3.so
note there is no gdb.setup file
I don't use debuggable=true in the manifest because it isn't needed anymore however including it has no affect on the result.
UPDATE: https://code.google.com/p/android/issues/detail?id=183455
This is exactly the problem I'm having. if you copy the target gdb.setup file from the target directory to the ./lib directory you can get ndk-gdb to work; The COMPAT_ABI variable in ndk-gdb isn't being set correctly and sending the script into a spin. I hope they fix this one soon. almost three days wasted on a broken tool chain.
UPDATE: https://code.google.com/p/android/issues/detail?id=183455 This is exactly the problem I'm having. if you copy the target gdb.setup file from the target directory to the ./lib directory you can get ndk-gdb to work; The COMPAT_ABI variable in ndk-gdb isn't being set correctly and sending the script into a spin. I hope they fix this one soon. almost three days wasted on a broken tool chain.
Jenkins Ruby metrics plugin cause error when copy .gitkeep file to log directory, because it fails to create log directory.
Error message is below.
Publishing rcov report...
ERROR: Publisher hudson.plugins.rubyMetrics.rcov.RcovPublisher aborted due to exception
Failed to copy /Users/Shared/Jenkins/Home/jobs/RailsApp/workspace/log/.gitkeep to /Users/Shared/Jenkins/Home/jobs/RailsApp/builds/2014-02-05_21-07-52/log/.gitkeep due to failed to create the parent directory for /Users/Shared/Jenkins/Home/jobs/RailsApp/builds/2014-02-05_21-07-52/log/.gitkeep
at org.apache.tools.ant.taskdefs.Copy.doFileOperations(Copy.java:914)
at org.apache.tools.ant.taskdefs.Copy.execute(Copy.java:567)
at hudson.Util.copyFile(Util.java:922)
at hudson.FilePath$38$1.visit(FilePath.java:1937)
at hudson.util.DirScanner.scanSingle(DirScanner.java:49)
at hudson.util.DirScanner$Glob.scan(DirScanner.java:131)
at hudson.FilePath$38.invoke(FilePath.java:1932)
at hudson.FilePath$38.invoke(FilePath.java:1925)
at hudson.FilePath.act(FilePath.java:914)
at hudson.FilePath.act(FilePath.java:887)
at hudson.FilePath.copyRecursiveTo(FilePath.java:1925)
at hudson.FilePath.copyRecursiveTo(FilePath.java:1911)
at hudson.FilePath.copyRecursiveTo(FilePath.java:1894)
at hudson.plugins.rubyMetrics.Utils.moveReportsToBuildRootDir(Utils.java:28)
at hudson.plugins.rubyMetrics.Utils.moveReportsToBuildRootDir(Utils.java:12)
at hudson.plugins.rubyMetrics.HtmlPublisher.prepareMetricsReportBeforeParse(HtmlPublisher.java:30)
at hudson.plugins.rubyMetrics.rcov.RcovPublisher.perform(RcovPublisher.java:50)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:784)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:756)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:705)
at hudson.model.Run.execute(Run.java:1695)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: java.io.IOException: failed to create the parent directory for /Users/Shared/Jenkins/Home/jobs/RailsApp/builds/2014-02-05_21-07-52/log/.gitkeep
at org.apache.tools.ant.util.ResourceUtils.copyResource(ResourceUtils.java:512)
at org.apache.tools.ant.util.FileUtils.copyFile(FileUtils.java:559)
at org.apache.tools.ant.taskdefs.Copy.doFileOperations(Copy.java:899)
... 25 more
Jenkins didn't create log 'directory' but log 'file'. Jenkins have permission to read/write of the directory of course. Any ideas? Thanks in advance.
I spend a lot of time to fix this issue.
In fact, when you activate the Ruby metrics plugin, you have to provide a directory. If you don't, the default folder is log, and it is the cause of your error.
So, go to your project configuration and in the Publish Rcov Report section, you just fill the directory.
Enjoy :)