0

I am using ANT to build an xml file but get the following error:

Error:[LoginFault [ApiFault exceptionCode='INVALID_LOGIN' exceptionMessage='Invalid username, password, security token; or user locked out.' extendedErrorDetails='{[0]}

I did the following

- Whitelisted IP
- Simplified my password
- Tried password with token
- Soql PermissionSetAssignment ModifyAllData = true, was true for user

The user login settings shows

Partner Product Invalid Password    Force.com Migration Tool    login.salesforce.com

Build.properties

sf.username = username
sf.password = pasword

sfprod.serverurl =  https://login.salesforce.com
sfsandbox.serverurl = https://test.salesforce.com

sf.maxPoll = 20

Build.xml

<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
  <property file="build.properties"/>
  <property environment="env"/>

  <!-- Setting default value for username, password and session id properties to empty String
      so unset values are treated as empty. Whitout this, ant expressions such as ${sf.username}
      will be treated literally
    -->

    <condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
    <condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
    <condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>

    <taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
      <classpath>
        <pathelement location="../ant-salesforce.jar" />
      </classpath>
    </taskdef>





    <!-- Retrieve package.xml file from a sandbox org -->
    <target name="retrieveSandbox">
      <mkdir dir="deploy"/>
      <!--Retrieve the contents into another directory -->
      <sf:retrieve username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sfsandbox.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="deploy" unpackaged="retrieve/package.xml"/>
      </target>

      <!-- Retrieve package.xml file from production -->
      <target name="retrieveProd">
        <mkdir dir="deploy"/>
        <!-- Retrieve the contents into another directory -->
        <sf:retrieve username="${sf.username}" password="{sf.password}" sessionId="${sf.sessionId}" serverurl="${sfprod.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="deploy" unpackaged="retrieve/package.xml"/>
        </target>




        <!-- Shows deploying code & running tests for code in directory -->
        <target name="deploySandbox">
          <!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
          <sf:deploy username="${sf.username.deploy}" password="${sf.password.deploy}" sessionId="${sf.sessionId}" serverurl="${sfsandbox.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="deploy" rollbackOnError="true" TestLevel="NoTestRun">
          </sf:deploy>
        </target>

        <!-- Shows deploying code & running tests for code in directory -->
        <target name="deployProd">
          <!-- Upload the contents of the "codepkg" directory, running the tests for just 1 class -->
          <sf:deploy username="${sf.username.deploy}" password="${sf.password.deploy}" sessionId="${sf.sessionId}" serverurl="${sfprod.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="deploy" rollbackOnError="true" TestLevel= "NoTestRun">
          </sf:deploy>
        </target>



        <target name="validateSandbox">
          <sf:deploy username="${sf.username.deploy}" password="${sf.password.deploy}" sessionId="${sf.sessionId}" serverurl="${sfsandbox.serverurl}" maxPoll="${sf.maxPoll}"
            deployRoot="deploy" checkOnly="true" TestLevel= "NoTestRun"/>
        </target>


        <target name="validateProd">
          <sf:deploy username="${sf.username.deploy}" password="${sf.password.deploy}" sessionId="${sf.sessionId}" serverurl="${sfprod.serverurl}" maxPoll="${sf.maxPoll}"
            deployRoot="deploy" checkOnly="true" TestLevel= "NoTestRun"/>
          </target>



        </project>
10
  • Can you also put your build code please!!
    – Raj
    Feb 22, 2020 at 14:38
  • That's strange. Have you tried connecting with another user? Feb 22, 2020 at 17:14
  • @Raj added the properties and xml file
    – Thomas
    Feb 23, 2020 at 9:23
  • @DavidCheng added the properties and xml file
    – Thomas
    Feb 23, 2020 at 9:23
  • are you appending security token with the password? Feb 23, 2020 at 9:24

1 Answer 1

0

For anyone who may bump into this.In my case() the $ sign was missing in password="{sf.password}" this needed to be password="${sf.password}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .