如何从终端或命令行创建 gitlab 项目 [英] How to create a gitlab project from terminal or command line

查看:38
本文介绍了如何从终端或命令行创建 gitlab 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有内部设置 gitlab 服务器.我想运行单独的 ant 脚本并在该 gitlab 服务器中创建一个项目.(无需在 gitlab UI 中创建新项目)

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)

在 ant 中,我可以使用 exec 可执行文件并运行 bash 命令.

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

以及如何将Visibility Level等参数发送到gitlab服务器来创建项目?

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

推荐答案

您需要使用 GitLab API 来创建项目

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

POST /projects

可选参数之一是:

visibility_level(可选):

  • 0 是私有的(必须为每个用户明确授予项目访问权限)

  • 10 是内部的(任何登录用户都可以克隆该项目),
  • 20 是公开的(无需任何身份验证即可克隆项目)
  • 使用私有令牌(和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"
    

    这篇关于如何从终端或命令行创建 gitlab 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆