4

I have internal setup gitlab server. I want to run separate ant script and create a project in that gitlab server. (without creating new project in gitlab UI)

In the ant i can use exec executable and run the bash commands.

And also how to send the Visibility Level and other parameters to gitlab server to create the project?

User19792255
  • 111
  • 2
  • 10

3 Answers3

5

You Would need to use the GitLab API to create a project

POST /projects

One of the optional parameters is:

visibility_level (optional):

  • 0 is Private (Project access must be granted explicitly for each user)
  • 10 is Internal (The project can be cloned by any logged in user),
  • 20 is Public (The project can be cloned without any authentication)

Using a private token (and jq):

curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" \
-H "Accept: application/json" \
-H "Content-type: application/json" \
-X POST \
--data-urlencode 'name=myproject' \
--data-urlencode 'visibility_level=0' \
"http://example.com/api/v3/projects"
ssi-anik
  • 2,998
  • 3
  • 23
  • 52
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3

To create a gitlab project from terminal or command line using HTTPS, these are the commands:

//In a desired local folder
git init
//Add all files to commit
git add -A
//Commit all
git commit -m "Inital version"
//Add an alias origin to master branch
git remote add origin https://gitlab.com/minhasaulas/2018/corporativos/ServidorEureka.git
//Push change to remote repository
git push origin master

If you want to create a gitlab project from terminal or command line using SSH visit this url: https://www.pluralsight.com/guides/using-git-and-github-on-windows

gilbriatore
  • 658
  • 7
  • 12
  • 1
    if I see it correctly this doesnt create a new project, but setup a local system to work with an existing project. For this you would still have to navigate to the webinterface and click "create new project". But still helpful though – MacMartin May 04 '20 at 10:00
2

@eli you are right! The last one is to an existing repository. The code below it to create a repository from terminal only:

    //In a desired local folder
    git init

    //Add all files to commit
    git add .

    //Commit all
    git commit -m "Inital version"

    //Push data to remote repository and to master branch
    git push --set-upstream https://gitlab.com/your_repository_name_go_here.git master
gilbriatore
  • 658
  • 7
  • 12