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的都知道,想要提交一段代码, ...
随机推荐
- device platform 相应的表
hw.machine 这个值相应相关代码最好在后台管理,降低手机端代码更新次数 if ([platform isEqualToString:@"iPhone1,1"]) retur ...
- 自由度(degree of freedom)
In many scientific fields, the degrees of freedom of a system is the number of parameters of the sys ...
- AWS核心服务概览
1.Amazon Web Service 应该可以说,Amazon Web Service目前是云计算领域的领头羊,其业务规模.开发水平和盈利能力在业界内都是首屈一指的.从本科毕业离开学校就一直做Ja ...
- angular form set dynamic control(form动态设置control)
实现效果 form表单控件的实时更新 效果如图 关键代码 validateForm: FormGroup; // 表单校验 constructor( private fb: FormBuilder ) ...
- XF 主从页面
using System; using Xamarin.Forms; using Xamarin.Forms.Xaml; [assembly: XamlCompilation (XamlCompila ...
- jquery 表格练习
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- 在云中生成和模拟 iOS
原文:在云中生成和模拟 iOS 1.原文地址 https://msdn.microsoft.com/zh-cn/library/vs/alm/dn858446.aspx
- 深入理解Amazon Alexa Skill(一)
语音助手(Virtual Personal Assistants, VPA)是物联网智能家居中很火的一个领域,用户可以通过语言作为入口来控制家里各种各样的设备,而亚马逊的Alexa(echo,echo ...
- MASMPlus汇编之简单窗体
.386 .model flat,stdcall option casemap:none ;include 定义 include windows.inc include gdi32.inc i ...
- 海康SDK编程指南
转至心澄欲遣 目前使用的海康SDK包括IPC_SDK(硬件设备),Plat_SDK(平台),其中两套SDK都需单独调用海康播放库PlayCtrl.dll来解码视频流,返回视频信息和角度信息.本文仅对视 ...