use of jetbrains.buildServer.vcs.SVcsRoot in project teamcity-rest by JetBrains.
the class BuildTypeRequest method getVcsRootEntryCheckoutRules.
@GET
@Path("/{btLocator}/vcs-root-entries/{vcsRootLocator}/" + VcsRootEntry.CHECKOUT_RULES)
@Produces({ "text/plain" })
@ApiOperation(value = "Get checkout rules of a VCS root of the matching build configuration.", nickname = "getVcsRootCheckoutRules")
public String getVcsRootEntryCheckoutRules(@ApiParam(format = LocatorName.BUILD_TYPE) @PathParam("btLocator") String buildTypeLocator, @ApiParam(format = LocatorName.VCS_ROOT) @PathParam("vcsRootLocator") String vcsRootLocator) {
final BuildTypeOrTemplate buildType = myBuildTypeFinder.getBuildTypeOrTemplate(null, buildTypeLocator, true);
final SVcsRoot vcsRoot = myVcsRootFinder.getItem(vcsRootLocator);
if (!buildType.get().containsVcsRoot(vcsRoot.getId())) {
throw new NotFoundException("VCS root with id '" + vcsRoot.getExternalId() + "' is not attached to the build type.");
}
return buildType.get().getCheckoutRules(vcsRoot).getAsString();
}
use of jetbrains.buildServer.vcs.SVcsRoot in project teamcity-rest by JetBrains.
the class VCSLabelingOptions method applyTo.
public void applyTo(final BuildTypeOrTemplate buildType, @NotNull final BeanContext context) {
if (labelName == null) {
throw new BadRequestException("Label name is not specified.");
}
if (type == null) {
throw new BadRequestException("Labeling type is not specified.");
}
BuildTypeSettings buildTypeSettings = buildType.get();
for (SBuildFeatureDescriptor feature : buildTypeSettings.getBuildFeatures()) {
if (feature.getType().equals(VcsLabelingBuildFeature.VCS_LABELING_TYPE)) {
buildTypeSettings.removeBuildFeature(feature.getId());
}
}
for (SVcsRoot vcsRoot : vcsRoots.getVcsRoots(context.getSingletonService(VcsRootFinder.class))) {
Map<String, String> params = new HashMap<String, String>();
params.put(VcsLabelingBuildFeature.VCS_ROOT_ID_PARAM, vcsRoot.getExternalId());
params.put(VcsLabelingBuildFeature.LABELING_PATTERN_PARAM, labelName);
if ("SUCCESSFUL_ONLY".equals(type)) {
params.put(VcsLabelingBuildFeature.SUCCESSFUL_ONLY_PARAM, "true");
}
if (branchFilter != null) {
params.put(VcsLabelingBuildFeature.BRANCH_FILTER_PARAM, branchFilter);
}
buildTypeSettings.addBuildFeature(VcsLabelingBuildFeature.VCS_LABELING_TYPE, params);
}
}
use of jetbrains.buildServer.vcs.SVcsRoot in project teamcity-git by JetBrains.
the class SpaceExternalChangeViewerExtension method getAvailableProperties.
@Nullable
@Override
public Map<String, String> getAvailableProperties(@NotNull VcsRoot vcs) {
final VcsRootInstance vcsRoot = (VcsRootInstance) vcs;
if (!Constants.VCS_NAME.equals(vcsRoot.getVcsName()))
return null;
String url = vcsRoot.getProperty(Constants.FETCH_URL);
if (url == null)
return null;
URIish uri;
try {
uri = new URIish(url);
} catch (URISyntaxException e) {
return null;
}
final String gitPath = uri.getPath();
if (uri.getHost().endsWith(".jetbrains.space")) {
// Space is on the Jetbrains side
final String[] strings = gitPath.substring(1).split("/");
if (strings.length == 3) {
final String orgName = strings[0];
final String project = strings[1];
final String repository = strings[2].replaceFirst("\\.git$", "");
final String repositoryUrl = String.format("https://%s.jetbrains.space/p/%s/repositories/%s", orgName, project, repository);
return createResponse(repositoryUrl);
}
} else {
final SVcsRoot vcsRootParent = vcsRoot.getParent();
final List<OAuthConnectionDescriptor> connections = myOAuthConnectionsManager.getAvailableConnectionsOfType(vcsRootParent.getProject(), SpaceOAuthProvider.TYPE);
if (connections.isEmpty())
return null;
for (OAuthConnectionDescriptor connection : connections) {
final SpaceConnectDescriber spaceConnectDescriber = new SpaceConnectDescriber(connection);
final String spaceAddress = spaceConnectDescriber.getAddress();
if (uri.getHost().contains(spaceAddress)) {
// Selfhosted Space
final String[] strings = gitPath.substring(1).split("/");
if (strings.length == 2) {
final String project = strings[0];
final String repository = strings[1].replaceFirst("\\.git$", "");
final String repositoryUrl = String.format("https://%s/p/%s/repositories/%s", spaceAddress, project, repository);
return createResponse(repositoryUrl);
}
}
}
}
return null;
}
use of jetbrains.buildServer.vcs.SVcsRoot in project teamcity-git by JetBrains.
the class GitHubPasswordAuthHealthPage method fillModel.
@Override
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
super.fillModel(model, request);
final SVcsRoot vcsRoot = getRootFromRequest(request);
if (vcsRoot == null)
return;
final String passwordProperty = vcsRoot.getProperty(Constants.PASSWORD);
model.put("isPasswordContainsReference", StringUtil.isNotEmpty(passwordProperty) && ReferencesResolverUtil.containsReference(passwordProperty));
}
use of jetbrains.buildServer.vcs.SVcsRoot in project teamcity-git by JetBrains.
the class SGitVcsRoot method getOrRefreshToken.
@Nullable
protected ExpiringAccessToken getOrRefreshToken(@NotNull String tokenId) {
VcsRoot vcsRoot = getOriginalRoot();
if (myTokenRefresher == null)
return null;
SVcsRoot parentRoot = vcsRoot instanceof SVcsRoot ? (SVcsRoot) vcsRoot : vcsRoot instanceof VcsRootInstance ? ((VcsRootInstance) vcsRoot).getParent() : null;
if (parentRoot == null) {
return myTokenRefresher.getRefreshableToken(vcsRoot.getExternalId(), tokenId);
} else {
return myTokenRefresher.getRefreshableToken(parentRoot.getProject(), tokenId);
}
}
Aggregations