How to create a project using gitlab-rails console?

try to create a gitlab project using gitlab-rails console but i did not find how to do that.

I found how to create a user :

u = User.new(username: 'name', email: 'name@example.com', name: 'Name name', password: 'password1234', password_confirmation: 'password1234', admin: true)
u.skip_confirmation!
u.save! 

But does someone know how to create project ? Or best where can i find a documentation about gitlab-rails objects ? Something like a javadoc would be helpfull …

Sincerly

I did not find how to create a project using gitlab-rails console, but I found a solution:

  • First create a user and set an API token to this user
  • Second create the project using Gitlab API

ruby script:

u = User.new(username: 'aName', email: 'aName@example.com', name: 'aName lastName ', password: 'password', password_confirmation: 'passworx', admin: true)                                          
u.skip_confirmation!
u.save!
token = u.personal_access_tokens.create(scopes: ['api','admin_mode'], name: 'install_token', expires_at: 365.days.from_now)
token.set_token('abcd1234')
token.save!

API request to create the project:

curl -k --request POST --header 'PRIVATE-TOKEN: abcd1234' --header 'Content-Type: application/json' --data  '{"name": "aName", "description": "example","namespace": "name", "initialize_with_readme": "true"}' --url 'https://www.example.com/api/v4/projects/'