title: Jenkins - Xcode build works codesign fails
body: <p>Below is my build script (not using xcodebuild plugin).</p>
  
  <ol>
  <li> Build step works</li>
  <li> I have created a separate keychain with the required certs and private keys, and they are visible in Keychain Access</li>
  <li> keychain commands don't fail in the script</li>
  <li> security list-keychains shows these as valid keychains</li>
  </ol>
  
  <p>It's acting like unlock command doesn't truly succeed.
  When I try to run codesign from the command line via</p>
  
  <pre><code>codesign -f -s "iPhone Developer: mycert" -v sample.app/ --keychain /Users/Shared/Jenkins/Library/Keychains/JenkinsCI.keychain
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>CSSM_SignData returned: 000186AD
  sample.app/: unknown error -2070=fffffffffffff7ea
  </code></pre>
  
  <p>although I'm not sure I'm emulating from the command line properly since you can at best </p>
  
  <pre><code>sudo -u jenkins bash
  
  xcodebuild ONLY_ACTIVE_ARCH="NO" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED="NO" -scheme "MySchemeName" CONFIGURATION_BUILD_DIR="`pwd`"
  security list-keychains -s /Users/Shared/Jenkins/Library/Keychains/JenkinsCI.keychain
  + security default-keychain -d user -s /Users/Shared/Jenkins/Library/Keychains/JenkinsCI.keychain
  + security unlock-keychain -p jenkins /Users/Shared/Jenkins/Library/Keychains/JenkinsCI.keychain
  + security list-keychains
      "/Users/Shared/Jenkins/Library/Keychains/JenkinsCI.keychain"
      "/Library/Keychains/System.keychain"
  + security default-keychain
      "/Users/Shared/Jenkins/Library/Keychains/JenkinsCI.keychain"
  + codesign -f -s '$IDENTITY_GOES_HERE.' -v sample.app/
  sample.app/: User interaction is not allowed.
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>