當前位置: 首頁>>代碼示例>>Java>>正文


Java GitHub.connectToEnterprise方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GitHub.connectToEnterprise方法的典型用法代碼示例。如果您正苦於以下問題:Java GitHub.connectToEnterprise方法的具體用法?Java GitHub.connectToEnterprise怎麽用?Java GitHub.connectToEnterprise使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GitHub的用法示例。


在下文中一共展示了GitHub.connectToEnterprise方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub getGitHub() throws IOException {
    final SettingsRepository settingsRepository = ServiceRegistry.getSettingsRepository();
    final String apiUrl = settingsRepository.getGitHubApiUrl();
    final String personalAccessToken = settingsRepository.getPersonalAccessToken();

    if (apiUrl != null) {
        if (personalAccessToken != null) {
            return GitHub.connectToEnterprise(apiUrl, personalAccessToken);
        } else {
            return GitHub.connectToEnterpriseAnonymously(apiUrl);
        }
    } else {
        if (personalAccessToken != null) {
            return GitHub.connectUsingOAuth(personalAccessToken);
        } else {
            return GitHub.connectAnonymously();
        }
    }
}
 
開發者ID:terma,項目名稱:github-pr-coverage-status,代碼行數:20,代碼來源:CachedGitHubRepository.java

示例2: deleteRepository

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * ɾ��ָ����repository
 * @param strRepoName Ҫɾ����github����
 * @return void
 */
public void deleteRepository(String strRepoName){
	GitHub github;
	GHRepository repo;
	try {
		System.out.println("Delete repo started!\t"+strRepoName);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		repo = github.getRepository(strRepoName);
		repo.delete();

		System.out.println("Delete repo finished!");

	} catch (IOException e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:24,代碼來源:GitRobot.java

示例3: createGitHubClient

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
GitHub createGitHubClient(String usernameToUse, String passwordToUse, String oauthAccessTokenToUse, String endPointToUse) throws Exception {
    GitHub github = null;
    if (usernameAndPasswordIsAvailable(usernameToUse, passwordToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectToEnterprise(endPointToUse, usernameToUse, passwordToUse);
        } else {
            github = GitHub.connectUsingPassword(usernameToUse, passwordToUse);
        }
    }
    if (oAuthTokenIsAvailable(oauthAccessTokenToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectUsingOAuth(endPointToUse, oauthAccessTokenToUse);
        } else {
            github = GitHub.connectUsingOAuth(oauthAccessTokenToUse);
        }
    }
    if (github == null) {
        github = GitHub.connect();
    }
    return github;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-build-status-notifier,代碼行數:22,代碼來源:GitHubProvider.java

示例4: createGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub createGitHub(String accessToken, GitHubConfiguration gitHubConfiguration) throws IOException {
    if (gitHubConfiguration.authenticateWith() == AuthenticateWith.GITHUB_ENTERPRISE) {
        LOG.debug("Create GitHub connection to enterprise GitHub with token");
        return GitHub.connectToEnterprise(gitHubConfiguration.gitHubEnterpriseUrl(), accessToken);
    } else {
        LOG.debug("Create GitHub connection to public GitHub with token");
        return GitHub.connectUsingOAuth(accessToken);
    }
}
 
開發者ID:gocd-contrib,項目名稱:github-oauth-authorization-plugin,代碼行數:10,代碼來源:GitHubClientBuilder.java

示例5: connectToEnterpriseGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub connectToEnterpriseGitHub(GithubPluginSettings pluginSettings) throws IOException {
    if (pluginSettings.containsUsernameAndPassword()) {
        LOGGER.debug("Create GitHub connection to enterprise GitHub using username and password");
        return GitHub.connectToEnterprise(
                pluginSettings.getApiUrl(),
                pluginSettings.getUsername(),
                pluginSettings.getPassword()
        );
    } else if (pluginSettings.containsOAuthToken()) {
        LOGGER.debug("Create GitHub connection to enterprise GitHub with token");
        return GitHub.connectToEnterprise(pluginSettings.getApiUrl(), pluginSettings.getOauthToken());
    }
    return null;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-oauth-login,代碼行數:15,代碼來源:GitHubProvider.java

示例6: createRepository

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * ����github��
 * @param strRepoName github����
 * @param strDescription ���� 
 * @param strUrl ��ҳ
 * @return void
 */
public void createRepository(String strRepoName, String strDescription, String strUrl){
	GitHub github;
	try {
		System.out.println("Create repo started!\t"+strRepoName);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		github.createRepository(strRepoName, strDescription, strUrl, true);
		System.out.println("Create repo finished!");
	} catch (IOException e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:21,代碼來源:GitRobot.java

示例7: getContents

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * �Ӹ�repository����������Դ
 * @param strRepoName github����
 * @param strLocalPath �����ļ���·��
 * @return void
 */
public void getContents(String strRepoName, String strRemotePath, String strLocalPath){
	GitHub github;
	GHRepository repo;
	try {
		if(strLocalPath.charAt(strLocalPath.length()-1) != '\\')
			strLocalPath += "\\";
		System.out.println("Download started!\t"+strRepoName + "/" + strRemotePath+" => " + strLocalPath);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		repo = github.getRepository( strRepoName);
		List<GHContent> contents = repo.getDirectoryContent(strRemotePath);
		Iterator it = contents.iterator();
		while(it.hasNext()){
			GHContent content = (GHContent)it.next();
			if(content.isDirectory()){
				getRepoDirectory(content, strRemotePath, strLocalPath);
			}
			else {
				String strFileName = strLocalPath + content.getName();
			
				if(content.getDownloadUrl() != null && content.getSize() < 1024 * 1024){
					writeFile(content.read(), strFileName);
				}
				else if(content.getGitUrl() != null){
					writeFileFromGitUrl(content.getGitUrl(), strFileName);
				}
			}
		}
		System.out.println("Download finished!");

	} catch(FileNotFoundException e1){
		System.out.println("Error:"+e1.getCause().getMessage()+"��Դ������");
		System.exit(0);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:46,代碼來源:GitRobot.java

示例8: deleteContents

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * ��ָ����repo����ɾ��ָ�����ļ���
 * @param strRepoName github����
 * @param strDirectory Ҫɾ�����ļ���
 * @return void
 */
public void deleteContents(String strRepoName, String strDirectory){
	GitHub github;
	GHRepository repo;
	try {
		System.out.println("Delete started!\t"+strRepoName+"/" + strDirectory);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		repo = github.getRepository(strRepoName);
		List<GHContent> lContents = null;
		try{
			lContents = repo.getDirectoryContent(strDirectory);
			Iterator<GHContent> it = lContents.iterator();
			while(it.hasNext()){
				GHContent content = it.next();
				if(content.isDirectory()){
					deleteContentsDir(repo, content.getPath());
					//content.delete("delete dir");
				}
				else{
					System.out.println("Deleted!\t" + content.getPath());
					content.delete("delete dir");
				}
			}
		}
		catch(FileNotFoundException ex){
			System.out.println(strDirectory + " does not exists.");
		}
		System.out.println("Delete finished!");
	} catch (Exception e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:41,代碼來源:GitRobot.java

示例9: updateContents

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * �ύ��Դ��ָ����repo��
 * @param strRepoName github����
 * @param strPath ����·��
 * @return void
 */
public void updateContents(String strRepoName, String strLocalPath, String strRemotePath){
	GitHub github;
	GHRepository repo;
	try {
		if(strLocalPath.charAt(strLocalPath.length()-1) != '\\')
			strLocalPath += "\\";
		if(strRemotePath.length() > 0 && strRemotePath.charAt(strRemotePath.length()-1) == '/')
			strRemotePath = strRemotePath.substring(0, strRemotePath.length()-1);
		System.out.println("Upload started!\t"+strLocalPath + " => " + strRepoName+"/"+strRemotePath);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		repo = github.getRepository( strRepoName);

		Path startingDir = Paths.get(strLocalPath);
		UpdateFileFinder finder = new UpdateFileFinder(repo, strRemotePath, strLocalPath, "*.*");
		Files.walkFileTree(startingDir, finder);
        finder.done();
		System.out.println("Upload finished!");
	} catch (Exception e) {
		// TODO Auto-generated catch block
		if(e.getClass().equals(FileNotFoundException.class)){
			System.out.println("Error:"+e.getCause().getMessage()+"�ֿⲻ����");
			System.exit(0);
		}
		else
			errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:35,代碼來源:GitRobot.java

示例10: doCreateApiToken

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public FormValidation doCreateApiToken(
		@QueryParameter("username") final String username,
        @QueryParameter("password") final String password){
	try{
		GitHub gh = GitHub.connectToEnterprise(this.serverAPIUrl, username, password);
		GHAuthorization token = gh.createToken(Arrays.asList(GHAuthorization.REPO_STATUS, GHAuthorization.REPO), "Jenkins GitHub Pull Request Builder", null);
		return FormValidation.ok("Access token created: " + token.getToken());
	}catch(IOException ex){
		return FormValidation.error("GitHub API token couldn't be created" + ex.getMessage());
	}
}
 
開發者ID:ds2wang,項目名稱:ghprb-copy,代碼行數:12,代碼來源:GhprbTrigger.java

示例11: getSingleContent

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * ���ص����ļ�
 * @param strRepoName �ֿ���
 * @param strRemoteFilePathWithName Զ�̿������Դ·��������src/test.txt)
 * @param strLocalFilePath Ҫ���ص��ı���·������Ҫ�����ļ���
 * @return void
 */
public void getSingleContent(String strRepoName, String strRemoteFilePathWithName, String strLocalFilePath){
	GitHub github;
	GHRepository repo;
	try {
		if(strLocalFilePath.charAt(strLocalFilePath.length()-1) != '\\')
			strLocalFilePath += "\\";
		System.out.println("Download started!\t"+strRepoName+"/"+strRemoteFilePathWithName+" => " + strLocalFilePath);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		int nLastSlashPos = strRemoteFilePathWithName.lastIndexOf('/');
		String strRemotePath = nLastSlashPos <= 0 ? "" : strRemoteFilePathWithName.substring(0, nLastSlashPos);
		String strRemoteFileName = nLastSlashPos == -1 ? strRemoteFilePathWithName : strRemoteFilePathWithName.substring(nLastSlashPos+1);
		repo = github.getRepository(strRepoName);
		List<GHContent> contents = repo.getDirectoryContent(strRemotePath);
		Iterator it = contents.iterator();
		boolean bDownloaded = false;
		while(it.hasNext()){
			GHContent content = (GHContent)it.next();
			if(content.getName().equalsIgnoreCase(strRemoteFileName)){
				if(content.isDirectory()){
					errHandle("This is a directory.");
					return;
				}
				else{
					String strFileName = strLocalFilePath + content.getName();
					if(content.getDownloadUrl() != null && content.getSize() < 1024 * 1024){
						writeFile(content.read(), strFileName);
						bDownloaded = true;
					}
					else if(content.getGitUrl() != null){
						writeFileFromGitUrl(content.getGitUrl(), strFileName);
						bDownloaded = true;
					}
				}
			}
		}
		if(bDownloaded)
			System.out.println("Download finished!");
		else
			errHandle("��Ŀ¼");
	} catch(FileNotFoundException e1){
		System.out.println("Error:"+e1.getCause().getMessage()+"��Դ������");
		System.exit(0);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:57,代碼來源:GitRobot.java


注:本文中的org.kohsuke.github.GitHub.connectToEnterprise方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。