Search code examples
gitlabgitlab-api

initial access token for gitlab


Is there an automated way to get a personal access token for the root user of gitlab after deploying? Trying to automate some post-deployment API configuration, but currently it requires creating a personal access token manually.


Solution

  • Found this finally.

    gitlab-rails runner "token = User.find_by_username('automation-bot').personal_access_tokens.create(scopes: [:read_user, :read_repository], name: 'Automation token'); token.set_token('token-string-here123'); token.save!"