GitLab通过API创建项目
示例:
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
import json
import requests
import subprocess
from ast import literal_eval
root = "/root/develop"
headers = {
"PRIVATE-TOKEN": "aljdhaguiqwackjaerigczx"
}
fromdata = {
"namespace_id": "41"
}
url = "http://ip:port/api/v4/projects"
def delete():
"""删除项目"""
response = requests.get(url, headers=headers)
tmp = json.loads(response.text)
for i in tmp:
project_name = i["name"]
requests.delete("http://ip:port/api/v4/projects/myscan-master%2f{}".format(project_name), headers=headers)
def create():
"""创建项目,复制代码"""
os.chdir("./deploy/")
names = os.listdir("./")
for i in names:
if os.path.isdir(i):
if i == ".git":
continue
fromdata["name"] = i
fromdata["path"] = i
if i != "component_all":
os.chdir(i)
subprocess.call("rm -rf .git build dist *.egg-info .idea .DS_Store ", shell=True)
pwd_1 = os.getcwd()
ssh_url = requests.post(url, data=fromdata, headers=headers)
subprocess.call("git clone -b develop {} {}/{}".format(ssh_url, root, i), shell=True)
os.chdir("{}/{}".format(root, i))
pwd_2 = os.getcwd()
subprocess.call("cp -rf {}/* {}/".format(pwd_1, pwd_2), shell=True)
subprocess.call("git push --set-upstream origin develop", shell=True)
subprocess.call('git add -A && git commit -m "create" && git push'.format(j), shell=True)
subprocess.call("rm -rf {}/{}".format(root, i))
os.chdir(pwd_1)
os.chdir("../")
else:
pass
def component():
"""组件"""
fromdata["name"] = "component_all"
fromdata["path"] = "component_all"
ssh_url = requests.post(url, data=fromdata, headers=headers)
subprocess.call("git clone -b develop {} {}/component_all".format(ssh_url, root), shell=True)
os.chdir("./deploy/component_all")
path = os.getcwd()
names = os.listdir("./")
for i in names:
os.chdir("{}/{}".format(path, i))
if os.path.isdir(i):
if i == ".git" or i == "README.md":
continue
subprocess.call("rm -rf .git build dist *.egg-info .idea .DS_Store ", shell=True)
pwd_1 = os.getcwd()
os.makedirs("{}/component_all/{}".format(root, i))
os.chdir("{}/component_all/{}".format(root, i))
pwd_2 = os.getcwd()
subprocess.call("cp -rf {}/* {}/".format(pwd_1, pwd_2), shell=True)
subprocess.call("git push --set-upstream origin develop", shell=True)
subprocess.call('git add -A && git commit -m "添加{}组件" && git push'.format(i), shell=True)
if __name__ == '__main__':
# 删除项目
delete()
# 复制项目
create()
# 复制组件
component()
GitLab通过API创建项目的更多相关文章
- gitlab通过api创建组、项目、成员
前戏 获取gitlab中admin用户的private_token Groups API 获取某个组的详细 curl --header "PRIVATE-TOKEN: *********&q ...
- Gitlab-通过API管理项目
Gitlab有一个非常强大的API,几乎可以通过API管理在Gitlab服务器中的所有项目. 在这里我们只是测试终端点的API, 因此我们需要一个程序来进行测试 .在这里我使用的是针对Google浏览 ...
- 【从零开始搭建自己的.NET Core Api框架】(一)创建项目并集成swagger:1.1 创建
系列目录 一. 创建项目并集成swagger 1.1 创建 1.2 完善 二. 搭建项目整体架构 三. 集成轻量级ORM框架——SqlSugar 3.1 搭建环境 3.2 实战篇:利用SqlSuga ...
- 从零开始学习 asp.net core 2.1 web api 后端api基础框架(二)-创建项目
原文:从零开始学习 asp.net core 2.1 web api 后端api基础框架(二)-创建项目 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.ne ...
- 01GitLab的使用——创建项目并上传到GitLab
借鉴:https://jingyan.baidu.com/article/9c69d48fe68cce13c9024e9c.html 登录GitLab网站,创建一个项目上传地址:https://blo ...
- Centos 7搭建Gitlab服务器以及操作(创建项目,创建群组,创建用户,添加密钥)
一. 安装并配置依赖包 在CentOS系统上安装所需的依赖:ssh,防火墙,postfix(用于邮件通知) ,wget,以下这些命令也会打开 系统防火墙中的HTTP和SSH端口访问 安装前准备 命令: ...
- ASP.NET+MVC入门踩坑笔记 (一) 创建项目 项目配置运行 以及简单的Api搭建
哈喽各位 我又回来了! 前段时间研究了下ASP.NET,刚开始也是随便找网上的各种教程来看,但是鉴于本人技术有限,还是走了相当长的一段弯路的.所以我写下了这篇文章.希望各位刚刚入坑的ASP.NET开发 ...
- gitlab怎么删除创建的项目
在gitlab新建了一个项目,怎么将此项目删除呢?打开这个工程,点击右上角的“settings”拉到最下面,有个show them to me,点击~在下拉选项的最后,有个remove框,点击即可以彻 ...
- gitlab官方api使用
目录 一.简介 二.技术要点 三.案例 一.简介 Gitlab作为一个开源.强大的分布式版本控制系统,已经成为互联网公司.软件开发公司的主流版本管理工具.使用过Gitlab的都知道,想要提交一段代码, ...
随机推荐
- Spring Assert.notNull--IllegalArgumentException
Exception in thread "main" java.lang.IllegalArgumentException: Source must not be null at ...
- 大约Android远程监控APP源代码
这篇文章的目的,关心询问名人,要打开源代码.这里说明,远程监控摄像头场外,相反,用手机摄像头摄像头server上,要理解这一点.关于非常网上的文章达到server道路.它能够准确,念就乱发博文,当然假 ...
- windows server疑难杂症
1.某些网址.服务访问失败,可能的原因:增强的安全配置关闭增强的安全配置,并且重启电脑!!!http://jingyan.baidu.com/article/6181c3e076ac0b152ff15 ...
- MVC基架生成的Edit视图
@model MyMusicStore.Models.Album @{ ViewBag.Title = "Edit"; } <h2>Edit</h2> ...
- git/github初级运用自如 (good)
三 . 设置用户信息 这一步不是很重要,貌似不设置也行,但github官方步骤中有,所以这里也提一下. 在git中设置用户名,邮箱 $ git config --global user.name &q ...
- 2017-01-11&2017-01-12
江门警情协作需求. 连续两天搞到超过十点半,所以今天来一并写一下这两天的记录吧. 1.11号明显的进展算是把通讯调通了,还有重新把协作请求的界面按一开始的设想嵌到主界面中. 2.今天12号貌似进展要大 ...
- 【Gerrit】Performance Cheat Sheet
首先说下做这件事情的主因,组内有人说Project repo sync有点慢,废话不多说,直接上图. 相关官方文档参考链接: 我的数据: ~/review_site/logs# fgrep " ...
- 启动组织重整 Marvell追求创新文化
最近接任Marvell技术长的Neil Kim正是该公司亟需的人才——他在今年四月加入后,预计将为Marvell带来正面.积极的改革契机,有机会让该公司彻底改头换面... 迈威尔科技(Marvell) ...
- delphi 线程教学第一节:初识多线程(讲的比较浅显),还有三个例子
http://www.cnblogs.com/lackey/p/6297115.html 几个例子: http://www.cnblogs.com/lackey/p/5371544.html
- 加载dll、lib库(例子的代码很全)
是关于如何加载dll或lib库的.可以看这篇bog Qt调用dll中的功能函数点击打开链接 **************************************************** ...