2

I am writing a shell script in bash (rewriting) that migrates / deploys our magento2 marketplace.

I started off by getting the latest release from github, but that makes it so i cannot use the admin-based web updater (which is the only place I can install our payment processor module because they don't upload to packagist) I don't want to attempt a sed edit on the package.json to add the repo and access keys, so I'm left trying to use the following command:

composer create-project --repository=https://repo.magento.com/ magento/project-community-edition

Of course, this requires I manually enter the access keys. i attempted to script it like this:

echo "a2dthisisnotreale1621a522a 21e9thisisnotreald4a183373" | composer create-project --repository=https://repo.magento.com/ magento/project-community-edition /var/www

I get an error stating You must be using the interactive console to authenticate. How am I supposed to do an unattended deploy? Our shop focuses primarily on continuous integration, and i cannot have our site be down for more than 20 minutes or so. It seems like every example of installing magento2 is from a non-automated method.

Has anyone tackled this problem? If so, how did you do it?

3 Answers 3

5

Another option is to set the access keys using the composer config command just before running the composer create-project command

composer config -g http-basic.repo.magento.com $MAGENTO_PUBLIC_KEY $MAGENTO_PRIVATE_KEY
composer create-project --repository=https://repo.magento.com/ magento/project-community-edition:2.3.* $PATH_TO_MAGENTO_ROOT
4

As usual, immediately after asking the question, i figure out the answer.

I need to add a file ~/.composer/auth.json with the following:

{
    "http-basic": {
        "repo.magento.com": {
            "username":"<your public key>",
            "password":"<your private key>"
        }
    }
}

Then I need to ensure that i create the folder, chown it to the user executing composer, and execute the command.

0

If someone still has trouble with getting magento 2 through composer because of authentication keys issue as given below, then make sure to update your auth.json with your Magento Authentication Keys (generated from marketplace.magento.com) inside your COMPOSER_HOME directory and then exit from your terminal / bash / shell and reopen it and try composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2/ command again to get Magento.

Detailed step by step instructions are given below:

Generate Authentication Keys inside your Magento Makeplace Account

https://marketplace.magento.com/customer/accessKeys/

Find your local machine composer home directory by typing the command below. It shows your composer path.

composer config --list --global | grep 'home'

In Windows 10 its like

C:/Users/youruser/AppData/Roaming/Composer

Open the auth.json inside the Composer Home directory (in a text-editor)

Update the file with your keys like given below

{
    "bitbucket-oauth": {},
    "github-oauth": {},
    "gitlab-oauth": {},
    "gitlab-token": {},
    "http-basic": {
        "repo.magento.com": {
            "username": "<your_public_key>",
            "password": "<your_private_key>"
        }
    },
    "bearer": {}
}

Exit the bash / shell / terminal and reopen it again and try the composer command to get the Magento package now. It will work.

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <your_magento2_install_dir>/

BTW my Composer version is 2.x. and am on Windows 10

$ composer --version
Composer version 2.0.8 2020-12-03 17:20:38

Hope this Helps !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.