操作背景 Gitlab是Docker部署,Jenkins账号登陆不了,开始是怀疑密码不对,通过控制台登陆重置了密码,还是登陆不了,怀疑是Jenkins用户被锁住了(默认错误登陆超过10次会锁定),解锁后登陆成功。
操作步骤 1.登陆Gitlab所在容器
代码语言:javascript复制[root@188-20 ~]# docker exec -it gitlab /bin/bash
root@gitlab:/# ls
RELEASE bin dev home lib64 mnt proc run srv tmp var
assets boot etc lib media opt root sbin sys usr
2.登陆控制台
代码语言:javascript复制root@gitlab:/# gitlab-rails console production
Loading production environment (Rails 4.2.10)
3.通过邮箱找到用户
代码语言:javascript复制irb(main):003:0> user=User.where(email:'jenkins@domian.com').first
=> #<User id:12 @jenkins>
4.修改密码并保存
代码语言:javascript复制irb(main):005:0> user.password=12345678
=> 12345678
irb(main):006:0> user.password_confirmation=12345678
=> 12345678
irb(main):007:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: 53d8c7ea-c523-43a1-a5e6-032c836f4870) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/22
=> true
5.解锁用户
代码语言:javascript复制irb(main):012:0> user=User.where(email:'jenkins@domain.com').first
=> #<User id:22 @jenkins>
irb(main):013:0> user.unlock_access!
=> true
irb(main):014:0>