jetbrains.buildServer.serverSide.SBuildType Java Examples

The following examples show how to use jetbrains.buildServer.serverSide.SBuildType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SQRPasswordProvider.java    From TeamCity.SonarQubePlugin with Apache License 2.0 6 votes vote down vote up
/**
 * @param buildType Build Configuration
 * @return SQSInfo in the Build Configuration or null
 */
@NotNull
private List<SQSInfo> findSQSInfos(@Nullable final SBuildType buildType) {
    if (buildType == null) {
        return Collections.emptyList();
    }
    final List<SQSInfo> res = new LinkedList<SQSInfo>();
    for (final SBuildRunnerDescriptor r : buildType.getBuildRunners()) {
        final String serverId = r.getParameters().get(Constants.SONAR_SERVER_ID);
        if (!Util.isEmpty(serverId)) {
            final SQSInfo server = mySqsManager.getServer(buildType.getProject(), serverId);
            if (server != null) {
                res.add(server);
            }
        }
    }
    return res;
}
 
Example #2
Source File: ProjectSlackNotificationsBean.java    From tcSlackBuildNotifier with MIT License 6 votes vote down vote up
public static ProjectSlackNotificationsBean build(SlackNotificationProjectSettings projSettings, SBuildType sBuildType, SProject project, SlackNotificationMainSettings mainSettings){
	ProjectSlackNotificationsBean bean = new ProjectSlackNotificationsBean();
	List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project);
	Set<String> enabledBuildTypes = new HashSet<String>();
	enabledBuildTypes.add(sBuildType.getBuildTypeId());
	
	bean.projectId = TeamCityIdResolver.getInternalProjectId(project);
	bean.slackNotificationList = new LinkedHashMap<String, SlacknotificationConfigAndBuildTypeListHolder>();
	
	/* Create a "new" config with blank stuff so that clicking the "new" button has a bunch of defaults to load in */
	SlackNotificationConfig newBlankConfig = new SlackNotificationConfig("", "", "", "", true, new BuildState().setAllEnabled(), false, false, enabledBuildTypes, true, true, true, true);
	newBlankConfig.setUniqueKey("new");
	/* And add it to the list */
	addSlackNotificationConfigHolder(bean, projectBuildTypes, newBlankConfig, mainSettings);
	
	/* Iterate over the rest of the slacknotifications in this project and add them to the json config */
	for (SlackNotificationConfig config : projSettings.getBuildSlackNotificationsAsList(sBuildType)){
		addSlackNotificationConfigHolder(bean, projectBuildTypes, config, mainSettings);
	}
	
	return bean;
	
}
 
Example #3
Source File: ProjectSlackNotificationsBean.java    From tcSlackBuildNotifier with MIT License 6 votes vote down vote up
public static ProjectSlackNotificationsBean build(SlackNotificationProjectSettings projSettings, SProject project, SlackNotificationMainSettings mainSettings){
	ProjectSlackNotificationsBean bean = new ProjectSlackNotificationsBean();
	List<SBuildType> projectBuildTypes = TeamCityIdResolver.getOwnBuildTypes(project);
	
	bean.projectId = TeamCityIdResolver.getInternalProjectId(project);
	bean.slackNotificationList = new LinkedHashMap<String, SlacknotificationConfigAndBuildTypeListHolder>();

	/* Create a "new" config with blank stuff so that clicking the "new" button has a bunch of defaults to load in */
	SlackNotificationConfig newBlankConfig = new SlackNotificationConfig("", "", "", "", true, new BuildState().setAllEnabled(), true, true, null, true, true, true, true);
	newBlankConfig.setUniqueKey("new");
	/* And add it to the list */
	addSlackNotificationConfigHolder(bean, projectBuildTypes, newBlankConfig, mainSettings);
	
	/* Iterate over the rest of the slacknotifications in this project and add them to the json config */
	for (SlackNotificationConfig config : projSettings.getSlackNotificationsAsList()){
		addSlackNotificationConfigHolder(bean, projectBuildTypes, config, mainSettings);
	}
	
	return bean;
	
}
 
Example #4
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public static String getInternalBuildIdOrNull(SBuildType buildType){
	try {
		return buildType.getInternalId();
	} catch (NoSuchMethodError ex) {
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return null;
	}
}
 
Example #5
Source File: ProjectSlackNotificationsBean.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
private static void addSlackNotificationConfigHolder(ProjectSlackNotificationsBean bean,
		List<SBuildType> projectBuildTypes, SlackNotificationConfig config, SlackNotificationMainSettings mainSettings) {
	SlacknotificationConfigAndBuildTypeListHolder holder = new SlacknotificationConfigAndBuildTypeListHolder(config, mainSettings);
	for (SBuildType sBuildType : projectBuildTypes){
		holder.addSlackNotificationBuildType(new SlacknotificationBuildTypeEnabledStatusBean(
												sBuildType.getBuildTypeId(), 
												sBuildType.getName(), 
												config.isEnabledForBuildType(sBuildType)
												)
									);
	}
	bean.slackNotificationList.put(holder.getUniqueKey(), holder);
}
 
Example #6
Source File: ProjectAndBuildSlacknotificationsBean.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public static ProjectAndBuildSlacknotificationsBean newInstance (SProject project, SlackNotificationProjectSettings settings, SBuildType sBuild) {
	ProjectAndBuildSlacknotificationsBean bean = new ProjectAndBuildSlacknotificationsBean();
	bean.project = project;
	bean.slackNotificationProjectSettings = settings;
	
	bean.projectSlacknotifications = settings.getProjectSlackNotificationsAsList();
	bean.buildSlacknotifications = new ArrayList<BuildSlacknotificationsBean>();
	
	if (sBuild != null && sBuild.getProjectId().equals(project.getProjectId())){
		bean.buildSlacknotifications.add(new BuildSlacknotificationsBean(sBuild, settings.getBuildSlackNotificationsAsList(sBuild)));
	}
	return bean;
}
 
Example #7
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
/**
 * Finds builds that belong the referenced project. Uses new method getOwnBuildTypes() if available.
 * Does not find builds in sub-projects.
 * @param project
 * @return List of BuildTypes corresponding to what is configured in the project.
 */
public static List<SBuildType> getOwnBuildTypes(SProject project) {
	try {
		return project.getOwnBuildTypes();
	} catch (NoSuchMethodError ex){
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return project.getBuildTypes();
	}
}
 
Example #8
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
/**
 * Finds a TeamCity BuiltType in the ProjectManager by buildTypeId.
 * Uses findBuildTypeByExternalId() if available, otherwise uses findBuildTypeById()
 * @param ProjectManager instance
 * @param buildTypeId string
 * @return TeamCity BuildType config object
 */
public static SBuildType findBuildTypeById(ProjectManager projectManager, String buildTypeId) {
	try {
		return projectManager.findBuildTypeByExternalId(buildTypeId);
	} catch (NoSuchMethodError ex){
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return projectManager.findBuildTypeById(buildTypeId);
	}
}
 
Example #9
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public static String getInternalBuildId(SBuildType buildType){
	try {
		return buildType.getInternalId();
	} catch (NoSuchMethodError ex) {
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return buildType.getBuildTypeId();
	}
}
 
Example #10
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public static String getExternalBuildIdOrNull(SBuildType buildType){
	try {
		return buildType.getExternalId();
	} catch (NoSuchMethodError ex) {
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return null;
	}
}
 
Example #11
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public static String getExternalBuildId(SBuildType buildType){
	try {
		return buildType.getExternalId();
	} catch (NoSuchMethodError ex) {
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return buildType.getBuildTypeId();
	}
}
 
Example #12
Source File: TeamCityIdResolver.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public static String getBuildTypeId(SBuildType buildType){
	try {
		return buildType.getExternalId();
	} catch (NoSuchMethodError ex) {
		LOGGER.log(Level.INFO,ex.getMessage(),ex);
		return buildType.getBuildTypeId();
	}
}
 
Example #13
Source File: ReportsFeature.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
protected void handleBuildFinished(SRunningBuild build) {
    final SBuildType bt = build.getBuildType();
    if (bt == null) {
        return;
    }

    for (SBuildFeatureDescriptor feature : bt.getBuildFeatures()) {
        if (getType().equalsIgnoreCase(feature.getType())) {
            handleBuildFinished(build, feature);
            break;
        }
    }
}
 
Example #14
Source File: SlackNotificationProjectSettings.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
public List<SlackNotificationConfig> getBuildSlackNotificationsAsList(SBuildType buildType){
	List<SlackNotificationConfig> buildHooks = new ArrayList<SlackNotificationConfig>();
	for (SlackNotificationConfig config : getSlackNotificationsAsList()){
		if (config.isSpecificBuildTypeEnabled(buildType)){
			buildHooks.add(config);
		}
	}
	return buildHooks;
}
 
Example #15
Source File: ReportsMain.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public SBuildType getBuildType() {
    return null;
}
 
Example #16
Source File: BuildSlacknotificationsBean.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
public void setsBuildType(SBuildType sBuildType) {
	this.sBuildType = sBuildType;
}
 
Example #17
Source File: BuildSlacknotificationsBean.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
public SBuildType getsBuildType() {
	return sBuildType;
}
 
Example #18
Source File: BuildSlacknotificationsBean.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
public BuildSlacknotificationsBean(SBuildType b, List<SlackNotificationConfig> c) {
	this.setsBuildType(b);
	this.setBuildConfigs(c);
}
 
Example #19
Source File: SlackNotificationBuildTabExtension.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	protected void fillModel(Map model, HttpServletRequest request,
			 @NotNull SBuildType buildType, SUser user) {
		this.settings = 
			(SlackNotificationProjectSettings)this.projSettings.getSettings(buildType.getProject().getProjectId(), SLACK_NOTIFICATIONS);
		
		List<ProjectAndBuildSlacknotificationsBean> projectAndParents = new ArrayList<ProjectAndBuildSlacknotificationsBean>();
		List<SProject> parentProjects = buildType.getProject().getProjectPath();
		parentProjects.remove(0);
		for (SProject projectParent : parentProjects){
			projectAndParents.add(
					ProjectAndBuildSlacknotificationsBean.newInstance(
							projectParent,
							(SlackNotificationProjectSettings) this.projSettings.getSettings(projectParent.getProjectId(), SLACK_NOTIFICATIONS),
							buildType
							)
					);
		}
		
//		projectAndParents.add(
//				ProjectAndBuildSlacknotificationsBean.newInstance(
//						project,
//						(SlackNotificationProjectSettings) this.projSettings.getSettings(project.getProjectId(), SLACK_NOTIFICATIONS),
//						true
//						)
//				);

		model.put("projectAndParents", projectAndParents);
    	
//    	List<SlackNotificationConfig> projectSlacknotifications = this.settings.getProjectSlackNotificationsAsList();
//    	List<SlackNotificationConfig> buildSlacknotifications = this.settings.getBuildSlackNotificationsAsList(buildType);
//    	
//    	model.put("projectSlackNotificationCount", projectSlacknotifications.size());
//    	if (projectSlacknotifications.size() == 0){
//    		model.put("noProjectSlackNotifications", "true");
//    		model.put("projectSlackNotifications", "false");
//    	} else {
//    		model.put("noProjectSlackNotifications", "false");
//    		model.put("projectSlackNotifications", "true");
//    		model.put("projectSlackNotificationList", projectSlacknotifications);
//    		model.put("projectSlackNotificationsDisabled", !this.settings.isEnabled());
//    	}
//    	
//    	model.put("buildSlackNotificationCount", buildSlacknotifications.size());
//    	if (buildSlacknotifications.size() == 0){
//    		model.put("noBuildSlackNotifications", "true");
//    		model.put("buildSlackNotifications", "false");
//    	} else {
//    		model.put("noBuildSlackNotifications", "false");
//    		model.put("buildSlackNotifications", "true");
//    		model.put("buildSlackNotificationList", buildSlacknotifications);
//    	}
//    	

    	model.put("projectId", buildType.getProject().getProjectId());
    	model.put("projectExternalId", TeamCityIdResolver.getExternalProjectId(buildType.getProject()));
    	model.put("projectName", buildType.getProject().getName());
    	
    	model.put("buildTypeId", buildType.getBuildTypeId());
    	model.put("buildExternalId", TeamCityIdResolver.getExternalBuildId(buildType));
    	model.put("buildName", buildType.getName());
	}
 
Example #20
Source File: SlackNotificationConfig.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
boolean isSpecificBuildTypeEnabled(SBuildType sBuildType){
	// Just check if this build type is only enabled for a specific build. 
	return enabledBuildTypesSet.contains(TeamCityIdResolver.getInternalBuildId(sBuildType));
}
 
Example #21
Source File: SlackNotificationConfig.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
public boolean isEnabledForBuildType(SBuildType sBuildType){
	// If allBuildTypes enabled, return true, otherwise  return whether the build is in the list of enabled buildTypes. 
	return isEnabledForAllBuildsInProject() || enabledBuildTypesSet.contains(TeamCityIdResolver.getInternalBuildId(sBuildType));
}
 
Example #22
Source File: SlackNotificationMockingFramework.java    From tcSlackBuildNotifier with MIT License votes vote down vote up
public SBuildType getSBuildTypeFromSubProject(); 
Example #23
Source File: SlackNotificationMockingFramework.java    From tcSlackBuildNotifier with MIT License votes vote down vote up
public SBuildType getSBuildType();