Is it possible to pass a password in Maven Deploy in the command line?

后端 未结 3 590
醉梦人生
醉梦人生 2020-12-15 16:06

This is the way it currently works, and it\'s the Maven Deploy Plugin Usage

pom.xml

[...]
  
    
            


        
相关标签:
3条回答
  • 2020-12-15 16:11

    This also works:

    <server>
      <id>${repo.id}</id>
      <username>${repo.username}</username>
      <password>${repo.password}</password>
    </server>
    
    0 讨论(0)
  • 2020-12-15 16:32

    I'll lay out here the full solution, but basically Robert Scholte's solution works brilliant.

    In your ~/.m2/settings.xml you should have the following

    <settings>
        <servers>
            <server>
                <id>${repo.id}</id>
                <username>${repo.login}</username>
                <password>${repo.pwd}</password>
            </server>
        </servers>
    </settings>  
    

    and then you just

    mvn -Drepo.id=myRepo -Drepo.login=someUser -Drepo.pwd=somePassword clean install

    You can even use your environment variable (if you are doing that on the remote server/container, for example):

    mvn -Drepo.id=$REPO_ID -Drepo.login=$REPO_LOGIN -Drepo.pwd=$REPO_PWD clean install

    0 讨论(0)
  • 2020-12-15 16:33

    The settings.xml is considered personal, so for that reason the username+password are stored in the (user-)settings.xml. So in general there's no reason to pass them as argument. (btw, passwords can be stored encrypted here) The maven-deploy-plugin has no option to pass them via commandline. However, I've seen hacks like:

    <username>${internal.repo.username}</username>
    

    And now you can do -Dinternal.repo.username=someUser

    0 讨论(0)
提交回复
热议问题