_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q8100 | ServerHelper.waitForDomain | train | public static void waitForDomain(final ModelControllerClient client, final long startupTimeout)
throws InterruptedException, RuntimeException, TimeoutException {
waitForDomain(null, client, startupTimeout);
} | java | {
"resource": ""
} |
q8101 | ServerHelper.shutdownDomain | train | public static void shutdownDomain(final ModelControllerClient client, final int timeout) throws IOException, OperationExecutionException {
// Note the following two operations used to shutdown a domain don't seem to work well in a composite operation.
// The operation occasionally sees a java.util.concurrent.CancellationException because the operation client
// is likely closed before the AsyncFuture.get() is complete. Using a non-composite operation doesn't seem to
// have this issue.
// First shutdown the servers
final ModelNode stopServersOp = Operations.createOperation("stop-servers");
stopServersOp.get("blocking").set(true);
stopServersOp.get("timeout").set(timeout);
ModelNode response = client.execute(stopServersOp);
if (!Operations.isSuccessfulOutcome(response)) {
throw new OperationExecutionException("Failed to stop servers.", stopServersOp, response);
}
// Now shutdown the host
final ModelNode address = determineHostAddress(client);
final ModelNode shutdownOp = Operations.createOperation("shutdown", address);
response = client.execute(shutdownOp);
if (Operations.isSuccessfulOutcome(response)) {
// Wait until the process has died
while (true) {
if (isDomainRunning(client, true)) {
try {
TimeUnit.MILLISECONDS.sleep(20L);
} catch (InterruptedException e) {
LOGGER.trace("Interrupted during sleep", e);
}
} else {
break;
}
}
} else {
throw new OperationExecutionException("Failed to shutdown host.", shutdownOp, response);
}
} | java | {
"resource": ""
} |
q8102 | ServerHelper.determineHostAddress | train | public static ModelNode determineHostAddress(final ModelControllerClient client) throws IOException, OperationExecutionException {
final ModelNode op = Operations.createReadAttributeOperation(EMPTY_ADDRESS, "local-host-name");
ModelNode response = client.execute(op);
if (Operations.isSuccessfulOutcome(response)) {
return DeploymentOperations.createAddress("host", Operations.readResult(response).asString());
}
throw new OperationExecutionException(op, response);
} | java | {
"resource": ""
} |
q8103 | ServerHelper.waitForStandalone | train | public static void waitForStandalone(final ModelControllerClient client, final long startupTimeout)
throws InterruptedException, RuntimeException, TimeoutException {
waitForStandalone(null, client, startupTimeout);
} | java | {
"resource": ""
} |
q8104 | ServerHelper.isStandaloneRunning | train | public static boolean isStandaloneRunning(final ModelControllerClient client) {
try {
final ModelNode response = client.execute(Operations.createReadAttributeOperation(EMPTY_ADDRESS, "server-state"));
if (Operations.isSuccessfulOutcome(response)) {
final String state = Operations.readResult(response).asString();
return !CONTROLLER_PROCESS_STATE_STARTING.equals(state)
&& !CONTROLLER_PROCESS_STATE_STOPPING.equals(state);
}
} catch (RuntimeException | IOException e) {
LOGGER.trace("Interrupted determining if standalone is running", e);
}
return false;
} | java | {
"resource": ""
} |
q8105 | ServerHelper.shutdownStandalone | train | public static void shutdownStandalone(final ModelControllerClient client, final int timeout) throws IOException {
final ModelNode op = Operations.createOperation("shutdown");
op.get("timeout").set(timeout);
final ModelNode response = client.execute(op);
if (Operations.isSuccessfulOutcome(response)) {
while (true) {
if (isStandaloneRunning(client)) {
try {
TimeUnit.MILLISECONDS.sleep(20L);
} catch (InterruptedException e) {
LOGGER.trace("Interrupted during sleep", e);
}
} else {
break;
}
}
} else {
throw new OperationExecutionException(op, response);
}
} | java | {
"resource": ""
} |
q8106 | PackageType.resolve | train | public static PackageType resolve(final MavenProject project) {
final String packaging = project.getPackaging().toLowerCase(Locale.ROOT);
if (DEFAULT_TYPES.containsKey(packaging)) {
return DEFAULT_TYPES.get(packaging);
}
return new PackageType(packaging);
} | java | {
"resource": ""
} |
q8107 | Environment.getJavaCommand | train | public static String getJavaCommand(final Path javaHome) {
final Path resolvedJavaHome = javaHome == null ? findJavaHome() : javaHome;
final String exe;
if (resolvedJavaHome == null) {
exe = "java";
} else {
exe = resolvedJavaHome.resolve("bin").resolve("java").toString();
}
if (exe.contains(" ")) {
return "\"" + exe + "\"";
}
if (WINDOWS) {
return exe + ".exe";
}
return exe;
} | java | {
"resource": ""
} |
q8108 | UndeployDescription.of | train | public static UndeployDescription of(final DeploymentDescription deploymentDescription) {
Assert.checkNotNullParam("deploymentDescription", deploymentDescription);
return of(deploymentDescription.getName()).addServerGroups(deploymentDescription.getServerGroups());
} | java | {
"resource": ""
} |
q8109 | DeploymentOperations.createDeployOperation | train | public static Operation createDeployOperation(final DeploymentDescription deployment) {
Assert.checkNotNullParam("deployment", deployment);
final CompositeOperationBuilder builder = CompositeOperationBuilder.create(true);
addDeployOperationStep(builder, deployment);
return builder.build();
} | java | {
"resource": ""
} |
q8110 | DeploymentOperations.createDeployOperation | train | public static Operation createDeployOperation(final Set<DeploymentDescription> deployments) {
Assertions.requiresNotNullOrNotEmptyParameter("deployments", deployments);
final CompositeOperationBuilder builder = CompositeOperationBuilder.create(true);
for (DeploymentDescription deployment : deployments) {
addDeployOperationStep(builder, deployment);
}
return builder.build();
} | java | {
"resource": ""
} |
q8111 | DeploymentOperations.addDeployOperationStep | train | static void addDeployOperationStep(final CompositeOperationBuilder builder, final DeploymentDescription deployment) {
final String name = deployment.getName();
final Set<String> serverGroups = deployment.getServerGroups();
// If the server groups are empty this is a standalone deployment
if (serverGroups.isEmpty()) {
final ModelNode address = createAddress(DEPLOYMENT, name);
builder.addStep(createOperation(DEPLOYMENT_DEPLOY_OPERATION, address));
} else {
for (String serverGroup : serverGroups) {
final ModelNode address = createAddress(SERVER_GROUP, serverGroup, DEPLOYMENT, name);
builder.addStep(createOperation(DEPLOYMENT_DEPLOY_OPERATION, address));
}
}
} | java | {
"resource": ""
} |
q8112 | DeploymentOperations.addRedeployOperationStep | train | private static void addRedeployOperationStep(final CompositeOperationBuilder builder, final DeploymentDescription deployment) {
final String deploymentName = deployment.getName();
final Set<String> serverGroups = deployment.getServerGroups();
if (serverGroups.isEmpty()) {
builder.addStep(createOperation(DEPLOYMENT_REDEPLOY_OPERATION, createAddress(DEPLOYMENT, deploymentName)));
} else {
for (String serverGroup : serverGroups) {
builder.addStep(createOperation(DEPLOYMENT_REDEPLOY_OPERATION, createAddress(SERVER_GROUP, serverGroup, DEPLOYMENT, deploymentName)));
}
}
} | java | {
"resource": ""
} |
q8113 | ServerOperations.getFailureDescriptionAsString | train | public static String getFailureDescriptionAsString(final ModelNode result) {
if (isSuccessfulOutcome(result)) {
return "";
}
final String msg;
if (result.hasDefined(ClientConstants.FAILURE_DESCRIPTION)) {
if (result.hasDefined(ClientConstants.OP)) {
msg = String.format("Operation '%s' at address '%s' failed: %s", result.get(ClientConstants.OP), result.get(ClientConstants.OP_ADDR), result
.get(ClientConstants.FAILURE_DESCRIPTION));
} else {
msg = String.format("Operation failed: %s", result.get(ClientConstants.FAILURE_DESCRIPTION));
}
} else {
msg = String.format("An unexpected response was found checking the deployment. Result: %s", result);
}
return msg;
} | java | {
"resource": ""
} |
q8114 | ServerOperations.createListDeploymentsOperation | train | public static ModelNode createListDeploymentsOperation() {
final ModelNode op = createOperation(READ_CHILDREN_NAMES);
op.get(CHILD_TYPE).set(DEPLOYMENT);
return op;
} | java | {
"resource": ""
} |
q8115 | ServerOperations.createRemoveOperation | train | public static ModelNode createRemoveOperation(final ModelNode address, final boolean recursive) {
final ModelNode op = createRemoveOperation(address);
op.get(RECURSIVE).set(recursive);
return op;
} | java | {
"resource": ""
} |
q8116 | ServerOperations.getChildAddress | train | public static Property getChildAddress(final ModelNode address) {
if (address.getType() != ModelType.LIST) {
throw new IllegalArgumentException("The address type must be a list.");
}
final List<Property> addressParts = address.asPropertyList();
if (addressParts.isEmpty()) {
throw new IllegalArgumentException("The address is empty.");
}
return addressParts.get(addressParts.size() - 1);
} | java | {
"resource": ""
} |
q8117 | ServerOperations.getParentAddress | train | public static ModelNode getParentAddress(final ModelNode address) {
if (address.getType() != ModelType.LIST) {
throw new IllegalArgumentException("The address type must be a list.");
}
final ModelNode result = new ModelNode();
final List<Property> addressParts = address.asPropertyList();
if (addressParts.isEmpty()) {
throw new IllegalArgumentException("The address is empty.");
}
for (int i = 0; i < addressParts.size() - 1; ++i) {
final Property property = addressParts.get(i);
result.add(property.getName(), property.getValue());
}
return result;
} | java | {
"resource": ""
} |
q8118 | MavenModelControllerClientConfiguration.getController | train | public String getController() {
final StringBuilder controller = new StringBuilder();
if (getProtocol() != null) {
controller.append(getProtocol()).append("://");
}
if (getHost() != null) {
controller.append(getHost());
} else {
controller.append("localhost");
}
if (getPort() > 0) {
controller.append(':').append(getPort());
}
return controller.toString();
} | java | {
"resource": ""
} |
q8119 | DefaultContainerDescription.lookup | train | static DefaultContainerDescription lookup(final ModelControllerClient client) throws IOException, OperationExecutionException {
final ModelNode op = Operations.createReadResourceOperation(new ModelNode().setEmptyList());
op.get(ClientConstants.INCLUDE_RUNTIME).set(true);
final ModelNode result = client.execute(op);
if (Operations.isSuccessfulOutcome(result)) {
final ModelNode model = Operations.readResult(result);
final String productName = getValue(model, "product-name", "WildFly");
final String productVersion = getValue(model, "product-version");
final String releaseVersion = getValue(model, "release-version");
final String launchType = getValue(model, "launch-type");
return new DefaultContainerDescription(productName, productVersion, releaseVersion, launchType, "DOMAIN".equalsIgnoreCase(launchType));
}
throw new OperationExecutionException(op, result);
} | java | {
"resource": ""
} |
q8120 | SimpleDeploymentDescription.of | train | public static SimpleDeploymentDescription of(final String name, @SuppressWarnings("TypeMayBeWeakened") final Set<String> serverGroups) {
final SimpleDeploymentDescription result = of(name);
if (serverGroups != null) {
result.addServerGroups(serverGroups);
}
return result;
} | java | {
"resource": ""
} |
q8121 | BuildInfoDeployer.addBuildInfoProperties | train | @Override
protected void addBuildInfoProperties(BuildInfoBuilder builder) {
if (envVars != null) {
for (Map.Entry<String, String> entry : envVars.entrySet()) {
builder.addProperty(BuildInfoProperties.BUILD_INFO_ENVIRONMENT_PREFIX + entry.getKey(), entry.getValue());
}
}
if (sysVars != null) {
for (Map.Entry<String, String> entry : sysVars.entrySet()) {
builder.addProperty(entry.getKey(), entry.getValue());
}
}
} | java | {
"resource": ""
} |
q8122 | UnifiedPromoteBuildAction.loadBuild | train | @JavaScriptMethod
@SuppressWarnings({"UnusedDeclaration"})
public LoadBuildsResponse loadBuild(String buildId) {
LoadBuildsResponse response = new LoadBuildsResponse();
// When we load a new build we need also to reset the promotion plugin.
// The null plugin is related to 'None' plugin.
setPromotionPlugin(null);
try {
this.currentPromotionCandidate = promotionCandidates.get(buildId);
if (this.currentPromotionCandidate == null) {
throw new IllegalArgumentException("Can't find build by ID: " + buildId);
}
List<String> repositoryKeys = getRepositoryKeys();
List<UserPluginInfo> plugins = getPromotionsUserPluginInfo();
PromotionConfig promotionConfig = getPromotionConfig();
String defaultTargetRepository = getDefaultPromotionTargetRepository();
if (StringUtils.isNotBlank(defaultTargetRepository) && repositoryKeys.contains(defaultTargetRepository)) {
promotionConfig.setTargetRepo(defaultTargetRepository);
}
response.addRepositories(repositoryKeys);
response.setPlugins(plugins);
response.setPromotionConfig(promotionConfig);
response.setSuccess(true);
} catch (Exception e) {
response.setResponseMessage(e.getMessage());
}
return response;
} | java | {
"resource": ""
} |
q8123 | UnifiedPromoteBuildAction.doIndex | train | @SuppressWarnings({"UnusedDeclaration"})
public void doIndex(StaplerRequest req, StaplerResponse resp) throws IOException, ServletException {
req.getView(this, chooseAction()).forward(req, resp);
} | java | {
"resource": ""
} |
q8124 | Utils.prepareArtifactoryServer | train | public static org.jfrog.hudson.ArtifactoryServer prepareArtifactoryServer(String artifactoryServerID,
ArtifactoryServer pipelineServer) {
if (artifactoryServerID == null && pipelineServer == null) {
return null;
}
if (artifactoryServerID != null && pipelineServer != null) {
return null;
}
if (pipelineServer != null) {
CredentialsConfig credentials = pipelineServer.createCredentialsConfig();
return new org.jfrog.hudson.ArtifactoryServer(null, pipelineServer.getUrl(), credentials,
credentials, pipelineServer.getConnection().getTimeout(), pipelineServer.isBypassProxy(), pipelineServer.getConnection().getRetry(), pipelineServer.getDeploymentThreads());
}
org.jfrog.hudson.ArtifactoryServer server = RepositoriesUtils.getArtifactoryServer(artifactoryServerID, RepositoriesUtils.getArtifactoryServers());
if (server == null) {
return null;
}
return server;
} | java | {
"resource": ""
} |
q8125 | Utils.appendBuildInfo | train | public static BuildInfo appendBuildInfo(CpsScript cpsScript, Map<String, Object> stepVariables) {
BuildInfo buildInfo = (BuildInfo) stepVariables.get(BUILD_INFO);
if (buildInfo == null) {
buildInfo = (BuildInfo) cpsScript.invokeMethod("newBuildInfo", Maps.newLinkedHashMap());
stepVariables.put(BUILD_INFO, buildInfo);
}
buildInfo.setCpsScript(cpsScript);
return buildInfo;
} | java | {
"resource": ""
} |
q8126 | PromotionUtils.promoteAndCheckResponse | train | public static boolean promoteAndCheckResponse(Promotion promotion, ArtifactoryBuildInfoClient client, TaskListener listener,
String buildName, String buildNumber) throws IOException {
// If failFast is true, perform dry run first
if (promotion.isFailFast()) {
promotion.setDryRun(true);
listener.getLogger().println("Performing dry run promotion (no changes are made during dry run) ...");
HttpResponse dryResponse = client.stageBuild(buildName, buildNumber, promotion);
try {
validatePromotionSuccessful(dryResponse, true, promotion.isFailFast(), listener);
} catch (IOException e) {
listener.error(e.getMessage());
return false;
}
listener.getLogger().println("Dry run finished successfully.\nPerforming promotion ...");
}
// Perform promotion
promotion.setDryRun(false);
HttpResponse response = client.stageBuild(buildName, buildNumber, promotion);
try {
validatePromotionSuccessful(response, false, promotion.isFailFast(), listener);
} catch (IOException e) {
listener.error(e.getMessage());
return false;
}
listener.getLogger().println("Promotion completed successfully!");
return true;
} | java | {
"resource": ""
} |
q8127 | FormValidations.validateEmails | train | public static FormValidation validateEmails(String emails) {
if (!Strings.isNullOrEmpty(emails)) {
String[] recipients = StringUtils.split(emails, " ");
for (String email : recipients) {
FormValidation validation = validateInternetAddress(email);
if (validation != FormValidation.ok()) {
return validation;
}
}
}
return FormValidation.ok();
} | java | {
"resource": ""
} |
q8128 | FormValidations.validateArtifactoryCombinationFilter | train | public static FormValidation validateArtifactoryCombinationFilter(String value)
throws IOException, InterruptedException {
String url = Util.fixEmptyAndTrim(value);
if (url == null)
return FormValidation.error("Mandatory field - You don`t have any deploy matches");
return FormValidation.ok();
} | java | {
"resource": ""
} |
q8129 | DistributionUtils.distributeAndCheckResponse | train | public static boolean distributeAndCheckResponse(DistributionBuilder distributionBuilder, ArtifactoryBuildInfoClient client, TaskListener listener,
String buildName, String buildNumber, boolean dryRun) throws IOException {
// do a dry run first
listener.getLogger().println("Performing dry run distribution (no changes are made during dry run) ...");
if (!distribute(distributionBuilder, client, listener, buildName, buildNumber, true)) {
return false;
}
listener.getLogger().println("Dry run finished successfully");
if (!dryRun) {
listener.getLogger().println("Performing distribution ...");
if (!distribute(distributionBuilder, client, listener, buildName, buildNumber, false)) {
return false;
}
listener.getLogger().println("Distribution completed successfully!");
}
return true;
} | java | {
"resource": ""
} |
q8130 | PublisherFlexible.getWrappedPublisher | train | private T getWrappedPublisher(Publisher flexiblePublisher, Class<T> type) {
if (!(flexiblePublisher instanceof FlexiblePublisher)) {
throw new IllegalArgumentException(String.format("Publisher should be of type: '%s'. Found type: '%s'",
FlexiblePublisher.class, flexiblePublisher.getClass()));
}
List<ConditionalPublisher> conditions = ((FlexiblePublisher) flexiblePublisher).getPublishers();
for (ConditionalPublisher condition : conditions) {
if (type.isInstance(condition.getPublisher())) {
return type.cast(condition.getPublisher());
}
}
return null;
} | java | {
"resource": ""
} |
q8131 | PublisherFlexible.find | train | public T find(AbstractProject<?, ?> project, Class<T> type) {
// First check that the Flexible Publish plugin is installed:
if (Jenkins.getInstance().getPlugin(FLEXIBLE_PUBLISH_PLUGIN) != null) {
// Iterate all the project's publishers and find the flexible publisher:
for (Publisher publisher : project.getPublishersList()) {
// Found the flexible publisher:
if (publisher instanceof FlexiblePublisher) {
// See if it wraps a publisher of the specified type and if it does, return it:
T pub = getWrappedPublisher(publisher, type);
if (pub != null) {
return pub;
}
}
}
}
return null;
} | java | {
"resource": ""
} |
q8132 | PublisherFlexible.isPublisherWrapped | train | public boolean isPublisherWrapped(AbstractProject<?, ?> project, Class<T> type) {
return find(project, type) != null;
} | java | {
"resource": ""
} |
q8133 | SubversionManager.commitWorkingCopy | train | public void commitWorkingCopy(final String commitMessage) throws IOException, InterruptedException {
build.getWorkspace().act(new SVNCommitWorkingCopyCallable(commitMessage, getLocation(),
getSvnAuthenticationProvider(build), buildListener));
} | java | {
"resource": ""
} |
q8134 | SubversionManager.createTag | train | public void createTag(final String tagUrl, final String commitMessage)
throws IOException, InterruptedException {
build.getWorkspace()
.act(new SVNCreateTagCallable(tagUrl, commitMessage, getLocation(), getSvnAuthenticationProvider(build),
buildListener));
} | java | {
"resource": ""
} |
q8135 | SubversionManager.revertWorkingCopy | train | public void revertWorkingCopy() throws IOException, InterruptedException {
build.getWorkspace()
.act(new RevertWorkingCopyCallable(getLocation(), getSvnAuthenticationProvider(build), buildListener));
} | java | {
"resource": ""
} |
q8136 | SubversionManager.safeRevertWorkingCopy | train | public void safeRevertWorkingCopy() {
try {
revertWorkingCopy();
} catch (Exception e) {
debuggingLogger.log(Level.FINE, "Failed to revert working copy", e);
log("Failed to revert working copy: " + e.getLocalizedMessage());
Throwable cause = e.getCause();
if (!(cause instanceof SVNException)) {
return;
}
SVNException svnException = (SVNException) cause;
if (svnException.getErrorMessage().getErrorCode() == SVNErrorCode.WC_LOCKED) {
// work space locked attempt cleanup and try to revert again
try {
cleanupWorkingCopy();
} catch (Exception unlockException) {
debuggingLogger.log(Level.FINE, "Failed to cleanup working copy", e);
log("Failed to cleanup working copy: " + e.getLocalizedMessage());
return;
}
try {
revertWorkingCopy();
} catch (Exception revertException) {
log("Failed to revert working copy on the 2nd attempt: " + e.getLocalizedMessage());
}
}
}
} | java | {
"resource": ""
} |
q8137 | IssuesTrackerHelper.setIssueTrackerInfo | train | public void setIssueTrackerInfo(BuildInfoBuilder builder) {
Issues issues = new Issues();
issues.setAggregateBuildIssues(aggregateBuildIssues);
issues.setAggregationBuildStatus(aggregationBuildStatus);
issues.setTracker(new IssueTracker("JIRA", issueTrackerVersion));
Set<Issue> affectedIssuesSet = IssuesTrackerUtils.getAffectedIssuesSet(affectedIssues);
if (!affectedIssuesSet.isEmpty()) {
issues.setAffectedIssues(affectedIssuesSet);
}
builder.issues(issues);
} | java | {
"resource": ""
} |
q8138 | BuildRetentionFactory.createBuildRetention | train | public static BuildRetention createBuildRetention(Run build, boolean discardOldArtifacts) {
BuildRetention buildRetention = new BuildRetention(discardOldArtifacts);
LogRotator rotator = null;
BuildDiscarder buildDiscarder = build.getParent().getBuildDiscarder();
if (buildDiscarder != null && buildDiscarder instanceof LogRotator) {
rotator = (LogRotator) buildDiscarder;
}
if (rotator == null) {
return buildRetention;
}
if (rotator.getNumToKeep() > -1) {
buildRetention.setCount(rotator.getNumToKeep());
}
if (rotator.getDaysToKeep() > -1) {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -rotator.getDaysToKeep());
buildRetention.setMinimumBuildDate(new Date(calendar.getTimeInMillis()));
}
List<String> notToBeDeleted = ExtractorUtils.getBuildNumbersNotToBeDeleted(build);
buildRetention.setBuildNumbersNotToBeDiscarded(notToBeDeleted);
return buildRetention;
} | java | {
"resource": ""
} |
q8139 | DockerUtils.getImageIdFromTag | train | public static String getImageIdFromTag(String imageTag, String host) throws IOException {
DockerClient dockerClient = null;
try {
dockerClient = getDockerClient(host);
return dockerClient.inspectImageCmd(imageTag).exec().getId();
} finally {
closeQuietly(dockerClient);
}
} | java | {
"resource": ""
} |
q8140 | DockerUtils.pushImage | train | public static void pushImage(String imageTag, String username, String password, String host) throws IOException {
final AuthConfig authConfig = new AuthConfig();
authConfig.withUsername(username);
authConfig.withPassword(password);
DockerClient dockerClient = null;
try {
dockerClient = getDockerClient(host);
dockerClient.pushImageCmd(imageTag).withAuthConfig(authConfig).exec(new PushImageResultCallback()).awaitSuccess();
} finally {
closeQuietly(dockerClient);
}
} | java | {
"resource": ""
} |
q8141 | DockerUtils.pullImage | train | public static void pullImage(String imageTag, String username, String password, String host) throws IOException {
final AuthConfig authConfig = new AuthConfig();
authConfig.withUsername(username);
authConfig.withPassword(password);
DockerClient dockerClient = null;
try {
dockerClient = getDockerClient(host);
dockerClient.pullImageCmd(imageTag).withAuthConfig(authConfig).exec(new PullImageResultCallback()).awaitSuccess();
} finally {
closeQuietly(dockerClient);
}
} | java | {
"resource": ""
} |
q8142 | DockerUtils.getParentId | train | public static String getParentId(String digest, String host) throws IOException {
DockerClient dockerClient = null;
try {
dockerClient = getDockerClient(host);
return dockerClient.inspectImageCmd(digest).exec().getParent();
} finally {
closeQuietly(dockerClient);
}
} | java | {
"resource": ""
} |
q8143 | DockerUtils.getLayersDigests | train | public static List<String> getLayersDigests(String manifestContent) throws IOException {
List<String> dockerLayersDependencies = new ArrayList<String>();
JsonNode manifest = Utils.mapper().readTree(manifestContent);
JsonNode schemaVersion = manifest.get("schemaVersion");
if (schemaVersion == null) {
throw new IllegalStateException("Could not find 'schemaVersion' in manifest");
}
boolean isSchemeVersion1 = schemaVersion.asInt() == 1;
JsonNode fsLayers = getFsLayers(manifest, isSchemeVersion1);
for (JsonNode fsLayer : fsLayers) {
JsonNode blobSum = getBlobSum(isSchemeVersion1, fsLayer);
dockerLayersDependencies.add(blobSum.asText());
}
dockerLayersDependencies.add(getConfigDigest(manifestContent));
//Add manifest sha1
String manifestSha1 = Hashing.sha1().hashString(manifestContent, Charsets.UTF_8).toString();
dockerLayersDependencies.add("sha1:" + manifestSha1);
return dockerLayersDependencies;
} | java | {
"resource": ""
} |
q8144 | DockerUtils.digestToFileName | train | public static String digestToFileName(String digest) {
if (StringUtils.startsWith(digest, "sha1")) {
return "manifest.json";
}
return getShaVersion(digest) + "__" + getShaValue(digest);
} | java | {
"resource": ""
} |
q8145 | DockerUtils.getNumberOfDependentLayers | train | public static int getNumberOfDependentLayers(String imageContent) throws IOException {
JsonNode history = Utils.mapper().readTree(imageContent).get("history");
if (history == null) {
throw new IllegalStateException("Could not find 'history' tag");
}
int layersNum = history.size();
boolean newImageLayers = true;
for (int i = history.size() - 1; i >= 0; i--) {
if (newImageLayers) {
layersNum--;
}
JsonNode layer = history.get(i);
JsonNode emptyLayer = layer.get("empty_layer");
if (!newImageLayers && emptyLayer != null) {
layersNum--;
}
if (layer.get("created_by") == null) {
continue;
}
String createdBy = layer.get("created_by").textValue();
if (createdBy.contains("ENTRYPOINT") || createdBy.contains("MAINTAINER")) {
newImageLayers = false;
}
}
return layersNum;
} | java | {
"resource": ""
} |
q8146 | MavenReleaseWrapper.getMavenModules | train | private List<String> getMavenModules(MavenModuleSetBuild mavenBuild) throws IOException, InterruptedException {
FilePath pathToModuleRoot = mavenBuild.getModuleRoot();
FilePath pathToPom = new FilePath(pathToModuleRoot, mavenBuild.getProject().getRootPOM(null));
return pathToPom.act(new MavenModulesExtractor());
} | java | {
"resource": ""
} |
q8147 | MavenReleaseWrapper.getRelativePomPath | train | private String getRelativePomPath(MavenModule mavenModule, MavenModuleSetBuild mavenBuild) {
String relativePath = mavenModule.getRelativePath();
if (StringUtils.isBlank(relativePath)) {
return POM_NAME;
}
// If this is the root module, return the root pom path.
if (mavenModule.getModuleName().toString().
equals(mavenBuild.getProject().getRootModule().getModuleName().toString())) {
return mavenBuild.getProject().getRootPOM(null);
}
// to remove the project folder name if exists
// keeps only the name of the module
String modulePath = relativePath.substring(relativePath.indexOf("/") + 1);
for (String moduleName : mavenModules) {
if (moduleName.contains(modulePath)) {
return createPomPath(relativePath, moduleName);
}
}
// In case this module is not in the parent pom
return relativePath + "/" + POM_NAME;
} | java | {
"resource": ""
} |
q8148 | MavenReleaseWrapper.createPomPath | train | private String createPomPath(String relativePath, String moduleName) {
if (!moduleName.contains(".xml")) {
// Inside the parent pom, the reference is to the pom.xml file
return relativePath + "/" + POM_NAME;
}
// There is a reference to another xml file, which is not the pom.
String dirName = relativePath.substring(0, relativePath.indexOf("/"));
return dirName + "/" + moduleName;
} | java | {
"resource": ""
} |
q8149 | MavenModulesExtractor.invoke | train | public List<String> invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
MavenProject mavenProject = getMavenProject(f.getAbsolutePath());
return mavenProject.getModel().getModules();
} | java | {
"resource": ""
} |
q8150 | ExtractorUtils.getVcsRevision | train | public static String getVcsRevision(Map<String, String> env) {
String revision = env.get("SVN_REVISION");
if (StringUtils.isBlank(revision)) {
revision = env.get(GIT_COMMIT);
}
if (StringUtils.isBlank(revision)) {
revision = env.get("P4_CHANGELIST");
}
return revision;
} | java | {
"resource": ""
} |
q8151 | ExtractorUtils.getVcsUrl | train | public static String getVcsUrl(Map<String, String> env) {
String url = env.get("SVN_URL");
if (StringUtils.isBlank(url)) {
url = publicGitUrl(env.get("GIT_URL"));
}
if (StringUtils.isBlank(url)) {
url = env.get("P4PORT");
}
return url;
} | java | {
"resource": ""
} |
q8152 | ExtractorUtils.daysBetween | train | private static long daysBetween(Date date1, Date date2) {
long diff;
if (date2.after(date1)) {
diff = date2.getTime() - date1.getTime();
} else {
diff = date1.getTime() - date2.getTime();
}
return diff / (24 * 60 * 60 * 1000);
} | java | {
"resource": ""
} |
q8153 | ExtractorUtils.getBuildNumbersNotToBeDeleted | train | public static List<String> getBuildNumbersNotToBeDeleted(Run build) {
List<String> notToDelete = Lists.newArrayList();
List<? extends Run<?, ?>> builds = build.getParent().getBuilds();
for (Run<?, ?> run : builds) {
if (run.isKeepLog()) {
notToDelete.add(String.valueOf(run.getNumber()));
}
}
return notToDelete;
} | java | {
"resource": ""
} |
q8154 | ExtractorUtils.entityToString | train | public static String entityToString(HttpEntity entity) throws IOException {
if (entity != null) {
InputStream is = entity.getContent();
return IOUtils.toString(is, "UTF-8");
}
return "";
} | java | {
"resource": ""
} |
q8155 | ExtractorUtils.createAndGetTempDir | train | public static FilePath createAndGetTempDir(final FilePath ws) throws IOException, InterruptedException {
// The token that combines the project name and unique number to create unique workspace directory.
String workspaceList = System.getProperty("hudson.slaves.WorkspaceList");
return ws.act(new MasterToSlaveCallable<FilePath, IOException>() {
@Override
public FilePath call() {
final FilePath tempDir = ws.sibling(ws.getName() + Objects.toString(workspaceList, "@") + "tmp").child("artifactory");
File tempDirFile = new File(tempDir.getRemote());
tempDirFile.mkdirs();
tempDirFile.deleteOnExit();
return tempDir;
}
});
} | java | {
"resource": ""
} |
q8156 | MavenDependenciesRecorder.postExecute | train | @Override
public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener,
Throwable error) {
//listener.getLogger().println("[MavenDependenciesRecorder] mojo: " + mojo.getClass() + ":" + mojo.getGoal());
//listener.getLogger().println("[MavenDependenciesRecorder] dependencies: " + pom.getArtifacts());
recordMavenDependencies(pom.getArtifacts());
return true;
} | java | {
"resource": ""
} |
q8157 | MavenDependenciesRecorder.postBuild | train | @Override
public boolean postBuild(MavenBuildProxy build, MavenProject pom, BuildListener listener)
throws InterruptedException, IOException {
build.executeAsync(new BuildCallable<Void, IOException>() {
// record is transient, so needs to make a copy first
private final Set<MavenDependency> d = dependencies;
public Void call(MavenBuild build) throws IOException, InterruptedException {
// add the action
//TODO: [by yl] These actions are persisted into the build.xml of each build run - we need another
//context to store these actions
build.getActions().add(new MavenDependenciesRecord(build, d));
return null;
}
});
return true;
} | java | {
"resource": ""
} |
q8158 | CredentialManager.getPreferredDeployer | train | public static CredentialsConfig getPreferredDeployer(DeployerOverrider deployerOverrider, ArtifactoryServer server) {
if (deployerOverrider.isOverridingDefaultDeployer()) {
CredentialsConfig deployerCredentialsConfig = deployerOverrider.getDeployerCredentialsConfig();
if (deployerCredentialsConfig != null) {
return deployerCredentialsConfig;
}
}
if (server != null) {
CredentialsConfig deployerCredentials = server.getDeployerCredentialsConfig();
if (deployerCredentials != null) {
return deployerCredentials;
}
}
return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG;
} | java | {
"resource": ""
} |
q8159 | Maven3Builder.perform | train | @Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
throws InterruptedException, IOException {
listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion());
EnvVars env = build.getEnvironment(listener);
FilePath workDir = build.getModuleRoot();
FilePath ws = build.getWorkspace();
FilePath mavenHome = getMavenHome(listener, env, launcher);
if (!mavenHome.exists()) {
listener.error("Couldn't find Maven home: " + mavenHome.getRemote());
throw new Run.RunnerAbortedException();
}
ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, ws, ws);
String[] cmds = cmdLine.toCommandArray();
return RunMaven(build, launcher, listener, env, workDir, cmds);
} | java | {
"resource": ""
} |
q8160 | Maven3Builder.perform | train | public boolean perform(Run<?, ?> build, Launcher launcher, TaskListener listener, EnvVars env, FilePath workDir, FilePath tempDir)
throws InterruptedException, IOException {
listener.getLogger().println("Jenkins Artifactory Plugin version: " + ActionableHelper.getArtifactoryPluginVersion());
FilePath mavenHome = getMavenHome(listener, env, launcher);
if (!mavenHome.exists()) {
listener.getLogger().println("Couldn't find Maven home at " + mavenHome.getRemote() + " on agent " + Utils.getAgentName(workDir) +
". This could be because this build is running inside a Docker container.");
}
ArgumentListBuilder cmdLine = buildMavenCmdLine(build, listener, env, launcher, mavenHome, workDir, tempDir);
String[] cmds = cmdLine.toCommandArray();
return RunMaven(build, launcher, listener, env, workDir, cmds);
} | java | {
"resource": ""
} |
q8161 | Maven3Builder.copyClassWorldsFile | train | private FilePath copyClassWorldsFile(FilePath ws, URL resource) {
try {
FilePath remoteClassworlds =
ws.createTextTempFile("classworlds", "conf", "");
remoteClassworlds.copyFrom(resource);
return remoteClassworlds;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | java | {
"resource": ""
} |
q8162 | ActionableHelper.getPublisher | train | public static <T extends Publisher> T getPublisher(AbstractProject<?, ?> project, Class<T> type) {
// Search for a publisher of the given type in the project and return it if found:
T publisher = new PublisherFindImpl<T>().find(project, type);
if (publisher != null) {
return publisher;
}
// If not found, the publisher might be wrapped by a "Flexible Publish" publisher. The below searches for it inside the
// Flexible Publisher:
publisher = new PublisherFlexible<T>().find(project, type);
return publisher;
} | java | {
"resource": ""
} |
q8163 | ActionableHelper.getArtifactoryPluginVersion | train | public static String getArtifactoryPluginVersion() {
String pluginsSortName = "artifactory";
//Validates Jenkins existence because in some jobs the Jenkins instance is unreachable
if (Jenkins.getInstance() != null
&& Jenkins.getInstance().getPlugin(pluginsSortName) != null
&& Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper() != null) {
return Jenkins.getInstance().getPlugin(pluginsSortName).getWrapper().getVersion();
}
return "";
} | java | {
"resource": ""
} |
q8164 | ActionableHelper.deleteFilePath | train | public static void deleteFilePath(FilePath workspace, String path) throws IOException {
if (StringUtils.isNotBlank(path)) {
try {
FilePath propertiesFile = new FilePath(workspace, path);
propertiesFile.delete();
} catch (Exception e) {
throw new IOException("Could not delete temp file: " + path);
}
}
} | java | {
"resource": ""
} |
q8165 | GitManager.getRemoteUrl | train | public String getRemoteUrl(String defaultRemoteUrl) {
if (StringUtils.isBlank(defaultRemoteUrl)) {
RemoteConfig remoteConfig = getJenkinsScm().getRepositories().get(0);
URIish uri = remoteConfig.getURIs().get(0);
return uri.toPrivateString();
}
return defaultRemoteUrl;
} | java | {
"resource": ""
} |
q8166 | RepositoryConf.getRepoKey | train | public String getRepoKey() {
String repoKey;
if (isDynamicMode()) {
repoKey = keyFromText;
} else {
repoKey = keyFromSelect;
}
return repoKey;
} | java | {
"resource": ""
} |
q8167 | Env.collectVariables | train | public void collectVariables(EnvVars env, Run build, TaskListener listener) {
EnvVars buildParameters = Utils.extractBuildParameters(build, listener);
if (buildParameters != null) {
env.putAll(buildParameters);
}
addAllWithFilter(envVars, env, filter.getPatternFilter());
Map<String, String> sysEnv = new HashMap<>();
Properties systemProperties = System.getProperties();
Enumeration<?> enumeration = systemProperties.propertyNames();
while (enumeration.hasMoreElements()) {
String propertyKey = (String) enumeration.nextElement();
sysEnv.put(propertyKey, systemProperties.getProperty(propertyKey));
}
addAllWithFilter(sysVars, sysEnv, filter.getPatternFilter());
} | java | {
"resource": ""
} |
q8168 | Env.append | train | protected void append(Env env) {
addAllWithFilter(this.envVars, env.envVars, filter.getPatternFilter());
addAllWithFilter(this.sysVars, env.sysVars, filter.getPatternFilter());
} | java | {
"resource": ""
} |
q8169 | Env.addAllWithFilter | train | private void addAllWithFilter(Map<String, String> toMap, Map<String, String> fromMap, IncludeExcludePatterns pattern) {
for (Object o : fromMap.entrySet()) {
Map.Entry entry = (Map.Entry) o;
String key = (String) entry.getKey();
if (PatternMatcher.pathConflicts(key, pattern)) {
continue;
}
toMap.put(key, (String) entry.getValue());
}
} | java | {
"resource": ""
} |
q8170 | DeployerResolverOverriderConverter.credentialsMigration | train | public void credentialsMigration(T overrider, Class overriderClass) {
try {
deployerMigration(overrider, overriderClass);
resolverMigration(overrider, overriderClass);
} catch (NoSuchFieldException | IllegalAccessException | IOException e) {
converterErrors.add(getConversionErrorMessage(overrider, e));
}
} | java | {
"resource": ""
} |
q8171 | DeployerResolverOverriderConverter.createInitialResolveDetailsFromDeployDetails | train | private ServerDetails createInitialResolveDetailsFromDeployDetails(ServerDetails deployerDetails) {
RepositoryConf oldResolveRepositoryConfig = deployerDetails.getResolveReleaseRepository();
RepositoryConf oldSnapshotResolveRepositoryConfig = deployerDetails.getResolveSnapshotRepository();
RepositoryConf resolverReleaseRepos = oldResolveRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldResolveRepositoryConfig;
RepositoryConf resolveSnapshotRepos = oldSnapshotResolveRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldSnapshotResolveRepositoryConfig;
return new ServerDetails(deployerDetails.getArtifactoryName(), deployerDetails.getArtifactoryUrl(),
null, null, resolverReleaseRepos, resolveSnapshotRepos, null, null);
} | java | {
"resource": ""
} |
q8172 | DeployerResolverOverriderConverter.createInitialDeployDetailsFromOldDeployDetails | train | private ServerDetails createInitialDeployDetailsFromOldDeployDetails(ServerDetails oldDeployerDetails) {
RepositoryConf oldDeployRepositoryConfig = oldDeployerDetails.getDeployReleaseRepository();
RepositoryConf oldSnapshotDeployRepositoryConfig = oldDeployerDetails.getDeploySnapshotRepository();
RepositoryConf deployReleaseRepos = oldDeployRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldDeployRepositoryConfig;
RepositoryConf deploySnapshotRepos = oldSnapshotDeployRepositoryConfig == null ? RepositoryConf.emptyRepositoryConfig : oldSnapshotDeployRepositoryConfig;
return new ServerDetails(oldDeployerDetails.getArtifactoryName(), oldDeployerDetails.getArtifactoryUrl(),
deployReleaseRepos, deploySnapshotRepos, null, null, null, null);
} | java | {
"resource": ""
} |
q8173 | PropertyUtils.loadGradleProperties | train | private static Properties loadGradleProperties(FilePath gradlePropertiesFilePath)
throws IOException, InterruptedException {
return gradlePropertiesFilePath.act(new MasterToSlaveFileCallable<Properties>() {
public Properties invoke(File gradlePropertiesFile, VirtualChannel channel) throws IOException, InterruptedException {
Properties gradleProps = new Properties();
if (gradlePropertiesFile.exists()) {
debuggingLogger.fine("Gradle properties file exists at: " + gradlePropertiesFile.getAbsolutePath());
FileInputStream stream = null;
try {
stream = new FileInputStream(gradlePropertiesFile);
gradleProps.load(stream);
} catch (IOException e) {
debuggingLogger.fine("IO exception occurred while trying to read properties file from: " +
gradlePropertiesFile.getAbsolutePath());
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(stream);
}
}
return gradleProps;
}
});
} | java | {
"resource": ""
} |
q8174 | DockerImage.generateBuildInfoModule | train | public Module generateBuildInfoModule(Run build, TaskListener listener, ArtifactoryConfigurator config, String buildName, String buildNumber, String timestamp) throws IOException {
if (artifactsProps == null) {
artifactsProps = ArrayListMultimap.create();
}
artifactsProps.put("build.name", buildName);
artifactsProps.put("build.number", buildNumber);
artifactsProps.put("build.timestamp", timestamp);
String artifactsPropsStr = ExtractorUtils.buildPropertiesString(artifactsProps);
Properties buildInfoItemsProps = new Properties();
buildInfoItemsProps.setProperty("build.name", buildName);
buildInfoItemsProps.setProperty("build.number", buildNumber);
buildInfoItemsProps.setProperty("build.timestamp", timestamp);
ArtifactoryServer server = config.getArtifactoryServer();
CredentialsConfig preferredResolver = server.getDeployerCredentialsConfig();
ArtifactoryDependenciesClient dependenciesClient = null;
ArtifactoryBuildInfoClient propertyChangeClient = null;
try {
dependenciesClient = server.createArtifactoryDependenciesClient(
preferredResolver.provideUsername(build.getParent()), preferredResolver.providePassword(build.getParent()),
server.createProxyConfiguration(Jenkins.getInstance().proxy), listener);
CredentialsConfig preferredDeployer = CredentialManager.getPreferredDeployer(config, server);
propertyChangeClient = server.createArtifactoryClient(
preferredDeployer.provideUsername(build.getParent()), preferredDeployer.providePassword(build.getParent()),
server.createProxyConfiguration(Jenkins.getInstance().proxy));
Module buildInfoModule = new Module();
buildInfoModule.setId(imageTag.substring(imageTag.indexOf("/") + 1));
// If manifest and imagePath not found, return.
if ((StringUtils.isEmpty(manifest) || StringUtils.isEmpty(imagePath)) && !findAndSetManifestFromArtifactory(server, dependenciesClient, listener)) {
return buildInfoModule;
}
listener.getLogger().println("Fetching details of published docker layers from Artifactory...");
boolean includeVirtualReposSupported = propertyChangeClient.getArtifactoryVersion().isAtLeast(VIRTUAL_REPOS_SUPPORTED_VERSION);
DockerLayers layers = createLayers(dependenciesClient, includeVirtualReposSupported);
listener.getLogger().println("Tagging published docker layers with build properties in Artifactory...");
setDependenciesAndArtifacts(buildInfoModule, layers, artifactsPropsStr, buildInfoItemsProps,
dependenciesClient, propertyChangeClient, server);
setBuildInfoModuleProps(buildInfoModule);
return buildInfoModule;
} finally {
if (dependenciesClient != null) {
dependenciesClient.close();
}
if (propertyChangeClient != null) {
propertyChangeClient.close();
}
}
} | java | {
"resource": ""
} |
q8175 | DockerImage.findAndSetManifestFromArtifactory | train | private boolean findAndSetManifestFromArtifactory(ArtifactoryServer server, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException {
String candidateImagePath = DockerUtils.getImagePath(imageTag);
String manifestPath;
// Try to get manifest, assuming reverse proxy
manifestPath = StringUtils.join(new String[]{server.getUrl(), targetRepo, candidateImagePath, "manifest.json"}, "/");
if (checkAndSetManifestAndImagePathCandidates(manifestPath, candidateImagePath, dependenciesClient, listener)) {
return true;
}
// Try to get manifest, assuming proxy-less
candidateImagePath = candidateImagePath.substring(candidateImagePath.indexOf("/") + 1);
manifestPath = StringUtils.join(new String[]{server.getUrl(), targetRepo, candidateImagePath, "manifest.json"}, "/");
if (checkAndSetManifestAndImagePathCandidates(manifestPath, candidateImagePath, dependenciesClient, listener)) {
return true;
}
// Couldn't find correct manifest
listener.getLogger().println("Could not find corresponding manifest.json file in Artifactory.");
return false;
} | java | {
"resource": ""
} |
q8176 | DockerImage.checkAndSetManifestAndImagePathCandidates | train | private boolean checkAndSetManifestAndImagePathCandidates(String manifestPath, String candidateImagePath, ArtifactoryDependenciesClient dependenciesClient, TaskListener listener) throws IOException {
String candidateManifest = getManifestFromArtifactory(dependenciesClient, manifestPath);
if (candidateManifest == null) {
return false;
}
String imageDigest = DockerUtils.getConfigDigest(candidateManifest);
if (imageDigest.equals(imageId)) {
manifest = candidateManifest;
imagePath = candidateImagePath;
return true;
}
listener.getLogger().println(String.format("Found incorrect manifest.json file in Artifactory in the following path: %s\nExpecting: %s got: %s", manifestPath, imageId, imageDigest));
return false;
} | java | {
"resource": ""
} |
q8177 | BuildInfo.getBuildFilesList | train | private List<org.jfrog.hudson.pipeline.types.File> getBuildFilesList(Stream<? extends BaseBuildFileBean> buildFilesStream) {
return buildFilesStream
.filter(buildFile -> StringUtils.isNotBlank(buildFile.getLocalPath()))
.filter(buildFile -> StringUtils.isNotBlank(buildFile.getRemotePath()))
.map(org.jfrog.hudson.pipeline.types.File::new)
.distinct()
.collect(Collectors.toList());
} | java | {
"resource": ""
} |
q8178 | ArtifactoryServer.getConnectionRetries | train | public List<Integer> getConnectionRetries() {
List<Integer> items = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
items.add(i);
}
return items;
} | java | {
"resource": ""
} |
q8179 | ArtifactoryServer.getResolvingCredentialsConfig | train | public CredentialsConfig getResolvingCredentialsConfig() {
if (resolverCredentialsConfig != null && resolverCredentialsConfig.isCredentialsProvided()) {
return getResolverCredentialsConfig();
}
if (deployerCredentialsConfig != null) {
return getDeployerCredentialsConfig();
}
return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG;
} | java | {
"resource": ""
} |
q8180 | PomTransformer.invoke | train | public Boolean invoke(File pomFile, VirtualChannel channel) throws IOException, InterruptedException {
org.jfrog.build.extractor.maven.reader.ModuleName current = new org.jfrog.build.extractor.maven.reader.ModuleName(
currentModule.groupId, currentModule.artifactId);
Map<org.jfrog.build.extractor.maven.reader.ModuleName, String> modules = Maps.newLinkedHashMap();
for (Map.Entry<ModuleName, String> entry : versionsByModule.entrySet()) {
modules.put(new org.jfrog.build.extractor.maven.reader.ModuleName(
entry.getKey().groupId, entry.getKey().artifactId), entry.getValue());
}
org.jfrog.build.extractor.maven.transformer.PomTransformer transformer =
new org.jfrog.build.extractor.maven.transformer.PomTransformer(current, modules, scmUrl,
failOnSnapshot);
return transformer.transform(pomFile);
} | java | {
"resource": ""
} |
q8181 | AbstractPerforceManager.edit | train | public void edit(int currentChangeListId, FilePath filePath) throws Exception {
establishConnection().editFile(currentChangeListId, new File(filePath.getRemote()));
} | java | {
"resource": ""
} |
q8182 | MavenExecutor.convertJdkPath | train | private void convertJdkPath(Launcher launcher, EnvVars extendedEnv) {
String separator = launcher.isUnix() ? "/" : "\\";
String java_home = extendedEnv.get("JAVA_HOME");
if (StringUtils.isNotEmpty(java_home)) {
if (!StringUtils.endsWith(java_home, separator)) {
java_home += separator;
}
extendedEnv.put("PATH+JDK", java_home + "bin");
}
} | java | {
"resource": ""
} |
q8183 | BuildUniqueIdentifierHelper.getRootBuild | train | public static AbstractBuild<?, ?> getRootBuild(AbstractBuild<?, ?> currentBuild) {
AbstractBuild<?, ?> rootBuild = null;
AbstractBuild<?, ?> parentBuild = getUpstreamBuild(currentBuild);
while (parentBuild != null) {
if (isPassIdentifiedDownstream(parentBuild)) {
rootBuild = parentBuild;
}
parentBuild = getUpstreamBuild(parentBuild);
}
if (rootBuild == null && isPassIdentifiedDownstream(currentBuild)) {
return currentBuild;
}
return rootBuild;
} | java | {
"resource": ""
} |
q8184 | BuildUniqueIdentifierHelper.getProject | train | private static AbstractProject<?, ?> getProject(String fullName) {
Item item = Hudson.getInstance().getItemByFullName(fullName);
if (item != null && item instanceof AbstractProject) {
return (AbstractProject<?, ?>) item;
}
return null;
} | java | {
"resource": ""
} |
q8185 | GitCoordinator.pushDryRun | train | public void pushDryRun() throws Exception {
if (releaseAction.isCreateVcsTag()) {
if (scmManager.isTagExists(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), releaseAction.getTagUrl())) {
throw new Exception(String.format("Tag with name '%s' already exists", releaseAction.getTagUrl()));
}
}
String testTagName = releaseAction.getTagUrl() + "_test";
try {
scmManager.testPush(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), testTagName);
} catch (Exception e) {
throw new Exception(String.format("Failed while attempting push dry-run: %s", e.getMessage()), e);
} finally {
if (scmManager.isTagExists(scmManager.getRemoteConfig(releaseAction.getTargetRemoteName()), testTagName)) {
scmManager.deleteLocalTag(testTagName);
}
}
} | java | {
"resource": ""
} |
q8186 | DockerAgentUtils.registerImagOnAgents | train | public synchronized static void registerImagOnAgents(Launcher launcher, final String imageTag,
final String host, final String targetRepo, final ArrayListMultimap<String, String> artifactsProps,
final int buildInfoId) throws IOException, InterruptedException {
// Master
final String imageId = getImageIdFromAgent(launcher, imageTag, host);
registerImage(imageId, imageTag, targetRepo, artifactsProps, buildInfoId);
// Agents
List<Node> nodes = Jenkins.getInstance().getNodes();
for (Node node : nodes) {
if (node == null || node.getChannel() == null) {
continue;
}
try {
node.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() {
public Boolean call() throws IOException {
registerImage(imageId, imageTag, targetRepo, artifactsProps, buildInfoId);
return true;
}
});
} catch (Exception e) {
launcher.getListener().getLogger().println("Could not register docker image " + imageTag +
" on Jenkins node '" + node.getDisplayName() + "' due to: " + e.getMessage() +
" This could be because this node is now offline."
);
}
}
} | java | {
"resource": ""
} |
q8187 | DockerAgentUtils.registerImage | train | private static void registerImage(String imageId, String imageTag, String targetRepo,
ArrayListMultimap<String, String> artifactsProps, int buildInfoId) throws IOException {
DockerImage image = new DockerImage(imageId, imageTag, targetRepo, buildInfoId, artifactsProps);
images.add(image);
} | java | {
"resource": ""
} |
q8188 | DockerAgentUtils.getImagesByBuildId | train | public static List<DockerImage> getImagesByBuildId(int buildInfoId) {
List<DockerImage> list = new ArrayList<DockerImage>();
Iterator<DockerImage> it = images.iterator();
while (it.hasNext()) {
DockerImage image = it.next();
if (image.getBuildInfoId() == buildInfoId && image.hasManifest()) {
list.add(image);
}
}
return list;
} | java | {
"resource": ""
} |
q8189 | DockerAgentUtils.getAndDiscardImagesByBuildId | train | public static List<DockerImage> getAndDiscardImagesByBuildId(int buildInfoId) {
List<DockerImage> list = new ArrayList<DockerImage>();
synchronized(images) {
Iterator<DockerImage> it = images.iterator();
while (it.hasNext()) {
DockerImage image = it.next();
if (image.getBuildInfoId() == buildInfoId) {
if (image.hasManifest()) {
list.add(image);
}
it.remove();
} else // Remove old images from the cache, for which build-info hasn't been published to Artifactory:
if (image.isExpired()) {
it.remove();
}
}
}
return list;
} | java | {
"resource": ""
} |
q8190 | DockerAgentUtils.getDockerImagesFromAgents | train | public static List<DockerImage> getDockerImagesFromAgents(final int buildInfoId, TaskListener listener) throws IOException, InterruptedException {
List<DockerImage> dockerImages = new ArrayList<DockerImage>();
// Collect images from the master:
dockerImages.addAll(getAndDiscardImagesByBuildId(buildInfoId));
// Collect images from all the agents:
List<Node> nodes = Jenkins.getInstance().getNodes();
for (Node node : nodes) {
if (node == null || node.getChannel() == null) {
continue;
}
try {
List<DockerImage> partialDockerImages = node.getChannel().call(new MasterToSlaveCallable<List<DockerImage>, IOException>() {
public List<DockerImage> call() throws IOException {
List<DockerImage> dockerImages = new ArrayList<DockerImage>();
dockerImages.addAll(getAndDiscardImagesByBuildId(buildInfoId));
return dockerImages;
}
});
dockerImages.addAll(partialDockerImages);
} catch (Exception e) {
listener.getLogger().println("Could not collect docker images from Jenkins node '" + node.getDisplayName() + "' due to: " + e.getMessage());
}
}
return dockerImages;
} | java | {
"resource": ""
} |
q8191 | DockerAgentUtils.pushImage | train | public static boolean pushImage(Launcher launcher, final JenkinsBuildInfoLog log, final String imageTag, final String username, final String password, final String host)
throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() {
public Boolean call() throws IOException {
String message = "Pushing image: " + imageTag;
if (StringUtils.isNotEmpty(host)) {
message += " using docker daemon host: " + host;
}
log.info(message);
DockerUtils.pushImage(imageTag, username, password, host);
return true;
}
});
} | java | {
"resource": ""
} |
q8192 | DockerAgentUtils.pullImage | train | public static boolean pullImage(Launcher launcher, final String imageTag, final String username, final String password, final String host)
throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() {
public Boolean call() throws IOException {
DockerUtils.pullImage(imageTag, username, password, host);
return true;
}
});
} | java | {
"resource": ""
} |
q8193 | DockerAgentUtils.updateImageParentOnAgents | train | public static boolean updateImageParentOnAgents(final JenkinsBuildInfoLog log, final String imageTag, final String host, final int buildInfoId) throws IOException, InterruptedException {
boolean parentUpdated = updateImageParent(log, imageTag, host, buildInfoId);
List<Node> nodes = Jenkins.getInstance().getNodes();
for (Node node : nodes) {
if (node == null || node.getChannel() == null) {
continue;
}
boolean parentNodeUpdated = node.getChannel().call(new MasterToSlaveCallable<Boolean, IOException>() {
public Boolean call() throws IOException {
return updateImageParent(log, imageTag, host, buildInfoId);
}
});
parentUpdated = parentUpdated ? parentUpdated : parentNodeUpdated;
}
return parentUpdated;
} | java | {
"resource": ""
} |
q8194 | DockerAgentUtils.getImageIdFromAgent | train | public static String getImageIdFromAgent(Launcher launcher, final String imageTag, final String host) throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() {
public String call() throws IOException {
return DockerUtils.getImageIdFromTag(imageTag, host);
}
});
} | java | {
"resource": ""
} |
q8195 | DockerAgentUtils.getParentIdFromAgent | train | public static String getParentIdFromAgent(Launcher launcher, final String imageID, final String host) throws IOException, InterruptedException {
return launcher.getChannel().call(new MasterToSlaveCallable<String, IOException>() {
public String call() throws IOException {
return DockerUtils.getParentId(imageID, host);
}
});
} | java | {
"resource": ""
} |
q8196 | BaseGradleReleaseAction.initBuilderSpecific | train | @Override
protected void initBuilderSpecific() throws Exception {
reset();
FilePath workspace = getModuleRoot(EnvVars.masterEnvVars);
FilePath gradlePropertiesPath = new FilePath(workspace, "gradle.properties");
if (releaseProps == null) {
releaseProps = PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getReleaseProperties());
}
if (nextIntegProps == null) {
nextIntegProps =
PropertyUtils.getModulesPropertiesFromPropFile(gradlePropertiesPath, getNextIntegProperties());
}
} | java | {
"resource": ""
} |
q8197 | BaseGradleReleaseAction.getModuleRoot | train | public FilePath getModuleRoot(Map<String, String> globalEnv) throws IOException, InterruptedException {
FilePath someWorkspace = project.getSomeWorkspace();
if (someWorkspace == null) {
throw new IllegalStateException("Couldn't find workspace");
}
Map<String, String> workspaceEnv = Maps.newHashMap();
workspaceEnv.put("WORKSPACE", someWorkspace.getRemote());
for (Builder builder : getBuilders()) {
if (builder instanceof Gradle) {
Gradle gradleBuilder = (Gradle) builder;
String rootBuildScriptDir = gradleBuilder.getRootBuildScriptDir();
if (rootBuildScriptDir != null && rootBuildScriptDir.trim().length() != 0) {
String rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptDir.trim(), workspaceEnv);
rootBuildScriptNormalized = Util.replaceMacro(rootBuildScriptNormalized, globalEnv);
return new FilePath(someWorkspace, rootBuildScriptNormalized);
} else {
return someWorkspace;
}
}
}
throw new IllegalArgumentException("Couldn't find Gradle builder in the current builders list");
} | java | {
"resource": ""
} |
q8198 | BaseGradleReleaseAction.extractNumericVersion | train | private String extractNumericVersion(Collection<String> versionStrings) {
if (versionStrings == null) {
return "";
}
for (String value : versionStrings) {
String releaseValue = calculateReleaseVersion(value);
if (!releaseValue.equals(value)) {
return releaseValue;
}
}
return "";
} | java | {
"resource": ""
} |
q8199 | ReleaseAction.init | train | @SuppressWarnings("UnusedDeclaration")
public void init() throws Exception {
initBuilderSpecific();
resetFields();
if (!UserPluginInfo.NO_PLUGIN_KEY.equals(getSelectedStagingPluginName())) {
PluginSettings selectedStagingPluginSettings = getSelectedStagingPlugin();
try {
stagingStrategy = getArtifactoryServer().getStagingStrategy(selectedStagingPluginSettings, Util.rawEncode(project.getName()), project);
} catch (Exception e) {
log.log(Level.WARNING, "Failed to obtain staging strategy: " + e.getMessage(), e);
strategyRequestFailed = true;
strategyRequestErrorMessage = "Failed to obtain staging strategy '" +
selectedStagingPluginSettings.getPluginName() + "': " + e.getMessage() +
".\nPlease review the log for further information.";
stagingStrategy = null;
}
strategyPluginExists = (stagingStrategy != null) && !stagingStrategy.isEmpty();
}
prepareDefaultVersioning();
prepareDefaultGlobalModule();
prepareDefaultModules();
prepareDefaultVcsSettings();
prepareDefaultPromotionConfig();
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.