jenkinsjenkins-cli

How to reset Jenkins Admin account password? I am running Jenkins in Docker in windows


I have created an Admin account in Jenkins after unlocking the Jenkins and doing the initial setup. Now I have forgot the password of the admin account and I am not able to login Jenkins


Solution

  • First, enter the docker container by using

    sudo docker exec -it [containerID] bin/bash
    

    Your container is likely clean and need to install editing tools (or just use vim if you like!), run

    apt-get update && apt-get install nano
    

    Then, find the config.xml file. For my container, it is in /var/jenkins_home/config.xml. You can also try /var/lib/jenkins/config.xml.

    nano /var/jenkins_home/config.xml
    

    Terminal Screen Cap Change the useSecurity tag to false.

    docker restart [ContainerID]
    

    Now, you can visit the Jenkins page and it should be showing the Dashboard right the way without password. You should reset the password, by going to Dashboard -> Manage Jenkins -> Security -> Configure Global Security , set Security Realms to Jenkins' own user database and press Apply.

    Next, go to People and click the admin account, you should be redirected and see a button named Configure, set a new set of password in Password section and press Apply.

    Then, go to Configure Global Security again, set Authentication to the option other than Anyone can do anything

    Your password should have been reset, finally, go set the value of useSecurity to true again and restart the container. Hope this help!