-
Bug
-
Resolution: Fixed
-
Major
-
None
-
Powered by SuggestiMate
I am trying to pass the parameter 'CODE_SIGN_IDENTITY="iPhone Distribution"' to xcodebuild via the new 'custom xcodebuild arguments' field. But no matter how I quote this it always gets split into two paramters at the whitespace which makes the build fail.
[JENKINS-12800] Can't add xcodebuild parameters including whitespace
@sweidauer as a workaround, in XCode, under your project "Build Settings", "Code Signing Identity":
1. Click on the configuration that lists your "iPhone Distribution" certificate.
2. Select "Other..."
3. Note the unique identifier for the certificate. Should be a long hex number.
4. Enter that in the custom xcodebuild arguments as CODE_SIGN_IDENTITY=ΧΧΧΧΧΧΧΧ-ΧΧΧΧ-ΧΧΧΧ-ΧΧΧΧ-ΧΧΧΧΧΧΧΧΧΧΧΧ
Turns out this isn't the correct identity for the certificate as it's not the SHA-1 key.
If identity consists of exactly forty hexadecimal digits, it is instead interpreted as the SHA-1 hash
of the certificate part of the desired identity. In this case, the identity's subject name is not con-
sidered.
You can find the identity of your certificate by using
security find-identity -p codesigning -v
However, even specifying this as the CODE_SIGN_IDENTITY doesn't seem to work as 'xcodebuild' complains with the following error.
[BEROR]Code Sign error: The identity 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' doesn't match any valid, non-expired certificate/private key pair in the default keychain
The only suggestion I have as a workaround is to search and replace the certificate in the project file as part of the build.
In Jenkins, under 'Build', 'Execute Shell', 'Command'
#!/bin/sh # Changing any signing certificate from an "iPhone Developer" to "iPhone Distribution" sed -i "" 's/CODE_SIGN_IDENTITY = \"iPhone Developer\";/CODE_SIGN_IDENTITY = \"iPhone Distribution\";/g' Foo.xcodeproj/project.pbxproj sed -i "" 's/\"CODE_SIGN_IDENTITY\[sdk=iphoneos\*\]\" = \"iPhone Developer\";/\"CODE_SIGN_IDENTITY\[sdk=iphoneos\*\]\" = \"iPhone Distribution\";/g' Foo.xcodeproj/project.pbxproj
I think you can parse this "Custom xcodebuild arguments" field using Java methods in hudson.Util class, such as tokenize(...) methods. These do use a QuotedStringTokenizer string tokenizer to take quoting into the account.
The work around I use is to set a
-xcconfig CodeSign.xcconfg
and set your
CODE_SIGN_IDENTITY="iPhone Distribution"
inside there.
We will look into it the patch.
In the meantime, have you tried escaping the spaces ?
CODE_SIGN_IDENTITY=iPhone\ Distribution
etc
I'm experiencing the same issue. I've also tried escaping in a variety of ways and all of them seem to fail.
CODE_SIGN_IDENTITY=iPhone\ Distribution:\ MangoDango,\ Inc
CODE_SIGN_IDENTITY="iPhone Distribution: MangoDango, Inc"
CODE_SIGN_IDENTITY="iPhone\ Distribution:\ MangoDango,\ Inc"
CODE_SIGN_IDENTITY='iPhone Distribution: MangoDango, Inc'
CODE_SIGN_IDENTITY=\"iPhone Distribution: MangoDango, Inc\"
CODE_SIGN_IDENTITY=iPhone\ Distribution\:\ MangoDango\,\ Inc
There doesn't seem to be any other way in the xcode plugin to specify code signing identities. It allows you to specify a provisioning profile, but not the code sign identity for the underlying xcrun command. Furthermore, there is a bug with that area as well. See JENKINS-14028.
Any other suggestions than the ones mentioned above?
I found a great workaround for building with jenkins.
Firstly, before setting up a job, download a jenkins plugin called:
Parameterized Trigger Plugin
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
Once you do that, create your job and while creating the job, select the
'This build is parameterized' checkbox
Create a String Parameter. I called mine CODE_SIGN_IDENTITY.
So the name field in the String Parameter should be:
--------------
Name: CODE_SIGN_IDENTITY
Default Value: iPhone Developer: XXX XXXXX
Description: Whatever you want to put there
--------------
Then in your Xcode Plugin, find the 'Custom xcodebuild arguments' field.
In the Custom xcodebuild arguments field, place the following value:
CODE_SIGN_IDENTITY=${CODE_SIGN_IDENTITY}
Finish setting up your job and you should be all set!
This will bypass the white space issue. The plugin is a life saver as it works wonderfully and you can customize your build with other parameters.
Code changed in jenkins
User: Victor Barros
Path:
src/main/java/au/com/rayh/XCodeBuilder.java
src/test/java/au/com/rayh/XCodeBuilderTest.java
http://jenkins-ci.org/commit/xcode-plugin/8b0e0525b9583fbfd90cebe56882a0bd0b5abf5b
Log:
fix for issue JENKINS-12800
https://issues.jenkins-ci.org/browse/JENKINS-12800
Code changed in jenkins
User: Jerome Lacoste
Path:
pom.xml
src/main/java/au/com/rayh/XCodeBuilder.java
src/test/java/au/com/rayh/XCodeBuilderTest.java
http://jenkins-ci.org/commit/xcode-plugin/d08553a852c2feb61ec016bb0940a3571b613a9d
Log:
Merge pull request #22 from heyzooi/master
fix for issue JENKINS-12800
Compare: https://github.com/jenkinsci/xcode-plugin/compare/17322cab642c...d08553a852c2
I can see the problem in the code because we split using space character.
https://github.com/jenkinsci/xcode-plugin/blob/master/src/main/java/au/com/rayh/XCodeBuilder.java#L392
I don't yet know how to solve it.
Perhaps using a most complexe regexp to not do it for spaces between characters ' or " but it's not easy.