Closed willardf closed 3 years ago
Hi @willardf How did you encode the content of the api key?
I'm experiencing the same issue using a service connection and in task fields as well. the command being run in the release task is:
021-02-24T18:24:11.1424680Z [command]/usr/local/lib/ruby/gems/2.7.0/bin/fastlane pilot upload --api_key_path /Users/runner/work/_temp/api_key***.json -i /Users/runner/work/r1/a/_PIPELINENAME/drop/output/iphoneos/Release QA/ourapp.ipa -a com.company.ourapp.qa -p 123456789
I didn't create an api_key****.json file; was I supposed to create this?
In the stack trace, I see a reference to where that key is trying to be read from "a file" here if it's value is null then on 63 the argumenterror occurs.
https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/connect_api/token.rb#L53
I have provided the contents of my API Key through the in task field as well as through service connection. I copy/pasted the contents of the .p8 file I downloaded from apple in the following format:
-----BEGIN PRIVATE KEY----- NotMyRealPrivateKeyButYouGetThePointMIGAMBMGByqKxW3ZWKlSZEQ9EeLajuO6VE7MO26rwDoHUcD +ax7gdR -----END PRIVATE KEY-----
Also, seeing this on the fastlane issues gh repo. It's culminating in a different area, but the error here "feels" the same. I need to try an earlier version of fastlane to see if it fixes the issue. Edit: https://github.com/fastlane/fastlane/issues/18271
Downgrading fastlane did nothing. I feel like the issue is in the key file being passed in... the "***" smells off to me; perusing through the codebase here it seems like that should "-keyid.json"
I tried outputting all files in that directory and it's actually empty. Something feels off in the creation of that file..
fastlane pilot upload --api_key_path /Users/runner/work/_temp/api_key***.json -i /Users/runner/work/r1/a/_PIPELINENAME/drop/output/iphoneos/Release QA/ourapp.ipa -a com.company.ourapp.qa -p 123456789
Ok, the ***.json; looks like is only happening when I use a service connection. When I use in task fields to specify an API Key connection, it sees the api_key{keyid}.json instead as passed in to the fastlane command.
I still get a similar error...
using the older version (2.158.0) just caused an error reading json as well. Seems like the file can't be found? but I'm not entirely sure if "the file" is actually there/being created. Added a bash task echoing some output and doing ls/cat of files in that dir, but I'm not seeing the console output of it in the logs...
Hi @jopache, You have to encode the content of .p8 file to base64 to use it in the task. You can try this tool or the following powershell snippet:
$api_key_content = '-----BEGIN PRIVATE KEY-----
YourPrivateKeyMIGAMBMGByqKxW3ZWKlSZEQ9EeLajuO6VE7MO26rwDoHUcD
Be6zkyp2SAUU99QS/3TPiKlOQ6agCgYIKoZIzj0DAQehRANCAAQTymeZ9NqX8rO
+ax7gdRMBMGByqKxW3ZWKlSZEMBMGByqKxW3ZWKlSZEMBMGByqKxW3ZW
-----END PRIVATE KEY-----'
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($api_key_content))
My apologies; that was the issue and it is now running. Thank you for the quick response!
@willardf Are you still experiencing this issue?
I also ran into a similar problem but solved it using the following in bash to get a valid base64-string
more your_key_file.p8 | base64
and then use the output.
@willardf feel free to reopen it if you still have issues
@max-zaytsev thanks, this helped us with Azure Dev Ops on the same problem. It was not clear in the documentation for Azure that you need to independently encode a text string into the base64 representation.
Using Hosted MacOS Azure Pipeline agents, the release task fails with the error at the bottom. Both a service connection and the in-task fields produce the same result. Recreating the commands with a bash script task, but using echo to create the jsonKeyFile seems to work fine.