调用gitlab Api无法创建master分支,同时将代码提交至master分支

通过调用gitlab Api实现创建master分支,并能将代码提交至master分支上

 GitlabAPI api ;
				try {
					//新建group
			    	GitlabGroup group = api.createGroup(name, path, null,       GitlabAccessLevel.Master, null);
			    	//新建project
			    	GitlabProject gitProj= api.createProjectForGroup(projectName, group );
			    	List list = api.getBranches(gitProj.getId());
			    	if(null == list || list .size() <= 0) {
			    		//新建branch1分支,然后再删除branch1分支,目的是只留下master分支
				    	api.createBranch(gitProj.getId(), "branch1",MASTER);
			    		api.deleteBranch(gitProj.getId(), "branch1");
			    	}
			    	//将人员添加至组中
			    	api.addGroupMember(group.getId(), userId,GitlabAccessLevel.Master ) 
			    	//developer可以提交代码至主干
		    	   api.protectBranchWithDeveloperOptions(gitProj, MASTER, true, true);
				}catch (Exception e) {
					e.printStackTrace();
				} 

你可能感兴趣的:(Java)