Skip to content
Advertisement

How to pull composer install inside docker container for Jfrog artifcatory

PHP package are install through Jfrog artifact URL using composer.json file. Need to get PHP package using composer install command inside docker container. This docker container manage by Jenkins pipeline. WHen I am doing locally it asked username and password on terminal

vagrant@sandbox1-xxxxx.dev.roc [ application ]$ composer update
Loading composer repositories with package information
                                                      
    Authentication required (example.jfrog.io):
      Username: example
      Password: 
Do you want to store credentials for example.jfrog.io in /home/vagrant/.composer/auth.json ? [Yn] y

Then it stored auth value under /home/vagrant/.composer/auth.json similar thing need to do in docker while deployment. what is way to do this ?

Advertisement

Answer

I got answer finally!

Jfrogtoken is configured under your Jenkins portal for token values.

Jenkins file you can add like this

withCredentials([string(credentialsId: 'Jfrogtoken', variable: 'secret')]) {
  jfrog_user = 'username'            
  jfrog_token = $secret
}

Pass this to docker file using --build-arg like

--build-arg jfrog_user=$jfrog_user --build-arg jfrog_token=$jfrog_token

Then you will received this params in Dockerfile under ARG value.

Then run this command before composer install. portal-url will be your jfrog account like example.jfrog.io

composer config --global http-basic.portal-url $jfrog_user $jfrog_token

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement