How to Prevent Gradle Builds from Locking Artifactory Accounts After Password Changes?

We often face an issue where changing the password for our Artifactory account leads to the account getting locked. This happens because we sometimes forget to update the credentials used by Gradle, and outdated credentials are used during dependency downloads, resulting in multiple failed login attempts.

Here is how we have defined the repository and credentials in build.gradle:

repositories {
    maven {
        url "https://artifactory.example.com/artifactory/libs-release"
        credentials {
            username = $artifactory_user
            password = $artifactory_password
        }
    }
}

The artifactory_user and artifactory_password values are stored in the gradle.properties file located in the users > .gradle directory, as shown below:

artifactory_user=your_username
artifactory_password=your_password

When we change the password for the Artifactory account, we sometimes forget to update the gradle.properties file. As a result, Gradle uses the outdated credentials, causing account lockouts due to multiple failed login attempts during dependency downloads.

What are the best practices or strategies to avoid account lockouts in this scenario?