Codemagic APP_STORE_CONNECT_PRIVATE_KEY Provided value is not valid
Asked Answered
R

1

7

I'm trying to sign the iOS build on Codemagic using YAML workflow. Following this document I encrypted and added the following environment variables:

  1. APP_STORE_CONNECT_KEY_IDENTIFIER
  2. APP_STORE_CONNECT_ISSUER_ID
  3. APP_STORE_CONNECT_PRIVATE_KEY
  4. CERTIFICATE_PRIVATE_KEY

On running the workflow I'm getting error Provided value "VALUE of APP_STORE_CONNECT_PRIVATE_KEY" is not valid. What to make this env variable value valid? I also tried adding base64 encoding for this value, but it still shows the same error.

Here's my codemagic.yaml file:

workflows:
  ios-workflow:
    name: iOS Workflow
    # instance_type: mac_mini
    max_build_duration: 120
    environment:
      groups:
        - store
      vars:
        XCODE_WORKSPACE: "Runner.xcworkspace"
        XCODE_SCHEME: "Runner"                
        BUNDLE_ID: "*MY_BUNDLE_ID*"
      flutter: stable
      xcode: latest
      cocoapods: default
    scripts:
      - name: Set up keychain to be used for codesigning using Codemagic CLI 'keychain' command
        script: |
                    keychain initialize
      - name: Fetch signing files
        script: |
# Failing command with invalid APP_STORE_CONNECT_PRIVATE_KEY
                    **app-store-connect fetch-signing-files $BUNDLE_ID --type IOS_APP_STORE --create**
      - name: Use system default keychain
        script: |
                    keychain add-certificates

Error:

File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 201, in invoke_cli CliApp._running_app = cls._create_instance(parser, args) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/cli_app.py", line 130, in _create_instance instance = cls.from_cli_args(cli_args) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/tools/app_store_connect.py", line 116, in from_cli_args private_key_argument = AppStoreConnectArgument.PRIVATE_KEY.from_args(cli_args) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/argument.py", line 55, in from_args return self.value.type.from_environment_variable_default() File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 42, in from_environment_variable_default
return cls(os.environ[cls.environment_variable_key], from_environment=True) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 33, in init self.value: T = self._parse_value() File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 129, in _parse_value return super()._parse_value() File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 57, in _parse_value return self._apply_type(value) File "/Users/builder/.pyenv/versions/3.8.7/lib/python3.8/site-packages/codemagic/cli/argument/typed_cli_argument.py", line 52, in _apply_type raise argparse.ArgumentTypeError(f'Provided value "{value}" is not valid') argparse.ArgumentTypeError: Provided value "VALUE of APP_STORE_CONNECT_PRIVATE_KEY" is not valid

Rozek answered 9/10, 2021 at 21:59 Comment(0)
C
4

make sure you downloaded the private API key from App Store Connect in .p8 format and copied the entire contents when paste into environment variable value field.

Crosspatch answered 10/10, 2021 at 10:35 Comment(2)
Yes, I'm pasting the entire file along with -----BEGIN PRIVATE KEY-----....-----END PRIVATE KEY-----. Still facing the same error.Rozek
Correction: I just put the entire key and it worked. Thanks for your input.Rozek

© 2022 - 2024 — McMap. All rights reserved.