Check Dependencies fails if using xcodebuild in CI

Hi everyone, I'm lost here.
Our CI builds on Jenkins nodes every now and then get into a state where Check Dependencies fails with exit status 65 since allegedly the file pointed to by the CODE_SIGN_ENTITLEMENTS build setting cannot be opened. The file is present however, since it is checked out from version control and its permissions seem to be fine as well. We do run a pre-action script before the build action that modifies this file to enable us to build with different sets of entitlements, though. This happens with both the old and the new build system by the way. Is it possible that pre-action scripts somehow run asynchronously or that .entitlements files are handled differently during Check Dependencies?
Answered by jzilske in 664363022
For the record: It seems that the problem was caused by xcodebuild not waiting for the pre-action script to complete before proceeding with the build. In that case the entitlements file was not present at the location pointed to by CODE_SIGN_ENTITLEMENTS (it is in fact not under version control there, it is instead copied there by the pre-action script and being gitignored afterwards). A reboot of the Jenkins node was enough to remedy the problem - at least for the time being. The CSSM errors mentioned above seem to be unrelated after all.
I have been watching the logs closely during on of the failing builds and I see codesign report a "UNIX error exception: 17" (EEXIST maybe?) followed by several CSSM errors (e.g. CSSMERR_DL_DATASTORE_DOESNOT_EXIST) before xcodebuild reports a "UNIX error exception: 22" (EINVAL?). Does that ring any bells?
Accepted Answer
For the record: It seems that the problem was caused by xcodebuild not waiting for the pre-action script to complete before proceeding with the build. In that case the entitlements file was not present at the location pointed to by CODE_SIGN_ENTITLEMENTS (it is in fact not under version control there, it is instead copied there by the pre-action script and being gitignored afterwards). A reboot of the Jenkins node was enough to remedy the problem - at least for the time being. The CSSM errors mentioned above seem to be unrelated after all.
Check Dependencies fails if using xcodebuild in CI
 
 
Q