aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildFilter.java24
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildListener.java4
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java10
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java2
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java20
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java6
6 files changed, 34 insertions, 32 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildFilter.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildFilter.java
index 7754106..6aa7344 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildFilter.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildFilter.java
@@ -46,7 +46,7 @@ abstract class Filter {
boolean apply = false;
while (srcMatch.find()) {
String computedFilter = ((srcMatch.group(1) == null ? "" : srcMatch.group(1)) + srcMatch.group(2)).trim();
- logger.log(Level.INFO, "Apply computed filter: {0}", computedFilter);
+ logger.log(Level.FINE, "Apply computed filter: {0}", computedFilter);
apply = apply || (computedFilter.isEmpty() ? true : usedFilter.apply(computedFilter, cause));
}
return apply;
@@ -71,7 +71,7 @@ class OnlySourceFlag extends Filter {
@Override
public boolean apply(String filter, BitbucketCause cause) {
String selectedRx = filter.startsWith(RX_FILTER_FLAG_SINGLE) ? filter.substring(RX_FILTER_FLAG_SINGLE.length()) : Pattern.quote(filter);
- logger.log(Level.INFO, "OnlySourceFlag using filter: {0}", selectedRx);
+ logger.log(Level.FINE, "OnlySourceFlag using filter: {0}", selectedRx);
Matcher matcher = Pattern.compile(selectedRx, Pattern.CASE_INSENSITIVE).matcher(cause.getSourceBranch());
return filter.startsWith(RX_FILTER_FLAG_SINGLE) ? matcher.find() : matcher.matches();
}
@@ -85,7 +85,7 @@ class OnlyDestFlag extends Filter {
@Override
public boolean apply(String filter, BitbucketCause cause) {
String selectedRx = filter.startsWith(RX_FILTER_FLAG_SINGLE) ? filter.substring(RX_FILTER_FLAG_SINGLE.length()) : Pattern.quote(filter);
- logger.log(Level.INFO, "OnlyDestFlag using filter: {0}", selectedRx);
+ logger.log(Level.FINE, "OnlyDestFlag using filter: {0}", selectedRx);
Matcher matcher = Pattern.compile(selectedRx, Pattern.CASE_INSENSITIVE).matcher(cause.getTargetBranch());
return filter.startsWith(RX_FILTER_FLAG_SINGLE) ? matcher.find() : matcher.matches();
}
@@ -117,7 +117,7 @@ class AuthorFlag extends Filter {
@Override
public boolean apply(String filter, BitbucketCause cause) {
String selectedRx = filter.startsWith(RX_FILTER_FLAG_SINGLE) ? filter.substring(RX_FILTER_FLAG_SINGLE.length()) : Pattern.quote(filter);
- logger.log(Level.INFO, "AuthorFlagImpl using filter: {0}", selectedRx);
+ logger.log(Level.FINE, "AuthorFlagImpl using filter: {0}", selectedRx);
Matcher matcher = Pattern.compile(selectedRx, Pattern.CASE_INSENSITIVE).matcher(cause.getPullRequestAuthor());
return filter.startsWith(RX_FILTER_FLAG_SINGLE) ? matcher.find() : matcher.matches();
}
@@ -188,29 +188,29 @@ public class BitbucketBuildFilter {
}
private void buildFilter(String filter) {
- logger.log(Level.INFO, "Build filter by phrase: {0}", filter);
+ logger.log(Level.FINE, "Build filter by phrase: {0}", filter);
for(Filter f : AvailableFilters) {
if (f.check(filter)) {
this.currFilter = f;
- logger.log(Level.INFO, "Using filter: {0}", f.getClass().getSimpleName());
+ logger.log(Level.FINE, "Using filter: {0}", f.getClass().getSimpleName());
break;
}
}
}
public boolean approved(BitbucketCause cause) {
- logger.log(Level.INFO, "Approve cause: {0}", cause.toString());
+ logger.log(Level.FINE, "Approve cause: {0}", cause.toString());
return this.currFilter.apply(this.filter, cause);
}
public static BitbucketBuildFilter instanceByString(String filter) {
- logger.log(Level.INFO, "Filter instance by filter string");
+ logger.log(Level.FINE, "Filter instance by filter string");
return new BitbucketBuildFilter(filter);
}
static public String filterFromGitSCMSource(AbstractGitSCMSource gitscm, String defaultFilter) {
if (gitscm == null) {
- logger.log(Level.INFO, "Git SCMSource unavailable. Using default value: {0}", defaultFilter);
+ logger.log(Level.FINE, "Git SCMSource unavailable. Using default value: {0}", defaultFilter);
return defaultFilter;
}
@@ -222,15 +222,15 @@ public class BitbucketBuildFilter {
}
}
- logger.log(Level.INFO, "Git includes transformation to filter result: {1} -> {0}; default: {2}", new Object[]{ filter, includes, defaultFilter });
+ logger.log(Level.FINE, "Git includes transformation to filter result: {1} -> {0}; default: {2}", new Object[]{ filter, includes, defaultFilter });
return filter.toString().trim();
}
public static BitbucketBuildFilter instanceBySCM(Collection<SCMSource> scmSources, String defaultFilter) {
- logger.log(Level.INFO, "Filter instance by using SCMSources list with {0} items", scmSources.size());
+ logger.log(Level.FINE, "Filter instance by using SCMSources list with {0} items", scmSources.size());
AbstractGitSCMSource gitscm = null;
for(SCMSource scm : scmSources) {
- logger.log(Level.INFO, "Check {0} SCMSource ", scm.getClass());
+ logger.log(Level.FINE, "Check {0} SCMSource ", scm.getClass());
if (scm instanceof AbstractGitSCMSource) {
gitscm = (AbstractGitSCMSource)scm;
break;
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildListener.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildListener.java
index 9e067e7..230253b 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildListener.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildListener.java
@@ -21,7 +21,7 @@ public class BitbucketBuildListener extends RunListener<Run<?, ?>> {
@Override
public void onStarted(Run r, TaskListener listener) {
- logger.info("BitbucketBuildListener onStarted called.");
+ logger.fine("BitbucketBuildListener onStarted called.");
BitbucketBuilds builds = builds(r);
if (builds != null) {
builds.onStarted((BitbucketCause) r.getCause(BitbucketCause.class), r);
@@ -30,7 +30,7 @@ public class BitbucketBuildListener extends RunListener<Run<?, ?>> {
@Override
public void onCompleted(Run r, @Nonnull TaskListener listener) {
- logger.info("BitbucketBuildListener onCompleted called.");
+ logger.fine("BitbucketBuildListener onCompleted called.");
BitbucketBuilds builds = builds(r);
if (builds != null) {
builds.onCompleted((BitbucketCause) r.getCause(BitbucketCause.class), r.getResult(), r.getUrl());
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
index bf3fd64..be36382 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
@@ -17,6 +17,7 @@ import jenkins.model.Jenkins;
import jenkins.model.ParameterizedJobMixIn;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
+import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
@@ -56,7 +57,6 @@ public class BitbucketBuildTrigger extends Trigger<Job<?, ?>> {
transient private BitbucketPullRequestsBuilder bitbucketPullRequestsBuilder;
- @Extension
public static final BitbucketBuildTriggerDescriptor descriptor = new BitbucketBuildTriggerDescriptor();
@DataBoundConstructor
@@ -216,7 +216,7 @@ public class BitbucketBuildTrigger extends Trigger<Job<?, ?>> {
for (Queue.Item item : queue.getItems()) {
if (hasCauseFromTheSamePullRequest(item.getCauses(), bitbucketCause)) {
- logger.info("Canceling item in queue: " + item);
+ logger.fine("Canceling item in queue: " + item);
queue.cancel(item);
}
}
@@ -236,7 +236,7 @@ public class BitbucketBuildTrigger extends Trigger<Job<?, ?>> {
if (o instanceof Run) {
Run build = (Run) o;
if (build.isBuilding() && hasCauseFromTheSamePullRequest(build.getCauses(), bitbucketCause)) {
- logger.info("Aborting build: " + build + " since PR is outdated");
+ logger.fine("Aborting build: " + build + " since PR is outdated");
setBuildDescription(build);
final Executor executor = build.getExecutor();
if (executor == null){
@@ -287,7 +287,7 @@ public class BitbucketBuildTrigger extends Trigger<Job<?, ?>> {
public void run() {
Job<?,?> project = this.getBuilder().getProject();
if (project instanceof AbstractProject && ((AbstractProject)project).isDisabled()) {
- logger.info("Build Skip.");
+ logger.fine("Build Skip.");
} else {
this.bitbucketPullRequestsBuilder.run();
this.getDescriptor().save();
@@ -299,6 +299,8 @@ public class BitbucketBuildTrigger extends Trigger<Job<?, ?>> {
super.stop();
}
+ @Extension
+ @Symbol("bitbucketpr")
public static final class BitbucketBuildTriggerDescriptor extends TriggerDescriptor {
public BitbucketBuildTriggerDescriptor() {
load();
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java
index 42fe562..4474581 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java
@@ -32,7 +32,7 @@ public class BitbucketPullRequestsBuilder {
}
public void run() {
- logger.info("Build Start.");
+ logger.fine("Build Start.");
this.repository.init();
Collection<Pullrequest> targetPullRequests = this.repository.getTargetPullRequests();
this.repository.addFutureBuildTasks(targetPullRequests);
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
index 352ec04..3b0a314 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
@@ -90,7 +90,7 @@ public class BitbucketRepository {
}
public Collection<Pullrequest> getTargetPullRequests() {
- logger.info("Fetch PullRequests.");
+ logger.fine("Fetch PullRequests.");
List<Pullrequest> pullRequests = client.getPullRequests();
List<Pullrequest> targetPullRequests = new ArrayList<Pullrequest>();
for(Pullrequest pullRequest : pullRequests) {
@@ -144,7 +144,7 @@ public class BitbucketRepository {
String repository = cause.getRepositoryName();
String destinationBranch = cause.getTargetBranch();
- logger.info("setBuildStatus " + state + " for commit: " + sourceCommit + " with url " + buildUrl);
+ logger.fine("setBuildStatus " + state + " for commit: " + sourceCommit + " with url " + buildUrl);
if (state == BuildState.FAILED || state == BuildState.SUCCESSFUL) {
comment = String.format(BUILD_DESCRIPTION, builder.getProject().getDisplayName(), sourceCommit, destinationBranch);
@@ -170,7 +170,7 @@ public class BitbucketRepository {
final static String CONTENT_PART_TEMPLATE = "```[bid: %s]```";
private List<String> getAvailableBuildTagsFromTTPComment(String buildTags) {
- logger.log(Level.INFO, "Parse {0}", new Object[]{ buildTags });
+ logger.log(Level.FINE, "Parse {0}", new Object[]{ buildTags });
List<String> availableBuildTags = new LinkedList<String>();
Matcher subBuildTagMatcher = SINGLE_BUILD_TAG_RX.matcher(buildTags);
while(subBuildTagMatcher.find()) availableBuildTags.add(subBuildTagMatcher.group(0).trim());
@@ -180,18 +180,18 @@ public class BitbucketRepository {
public boolean hasMyBuildTagInTTPComment(String content, String buildKey) {
Matcher tagsMatcher = BUILD_TAGS_RX.matcher(content);
if (tagsMatcher.find()) {
- logger.log(Level.INFO, "Content {0} g[1]:{1} mykey:{2}", new Object[] { content, tagsMatcher.group(1).trim(), this.getMyBuildTag(buildKey) });
+ logger.log(Level.FINE, "Content {0} g[1]:{1} mykey:{2}", new Object[] { content, tagsMatcher.group(1).trim(), this.getMyBuildTag(buildKey) });
return this.getAvailableBuildTagsFromTTPComment(tagsMatcher.group(1).trim()).contains(this.getMyBuildTag(buildKey));
}
else return false;
}
private void postBuildTagInTTPComment(String pullRequestId, String content, String buildKey) {
- logger.log(Level.INFO, "Update build tag for {0} build key", buildKey);
+ logger.log(Level.FINE, "Update build tag for {0} build key", buildKey);
List<String> builds = this.getAvailableBuildTagsFromTTPComment(content);
builds.add(this.getMyBuildTag(buildKey));
content += " " + String.format(CONTENT_PART_TEMPLATE, StringUtils.join(builds, " "));
- logger.log(Level.INFO, "Post comment: {0} with original content {1}", new Object[]{ content, this.client.postPullRequestComment(pullRequestId, content).getId() });
+ logger.log(Level.FINE, "Post comment: {0} with original content {1}", new Object[]{ content, this.client.postPullRequestComment(pullRequestId, content).getId() });
}
private boolean isTTPComment(String content) {
@@ -208,7 +208,7 @@ public class BitbucketRepository {
}
public List<Pullrequest.Comment> filterPullRequestComments(List<Pullrequest.Comment> comments) {
- logger.info("Filter PullRequest Comments.");
+ logger.fine("Filter PullRequest Comments.");
Collections.sort(comments);
Collections.reverse(comments);
List<Pullrequest.Comment> filteredComments = new LinkedList<Pullrequest.Comment>();
@@ -241,7 +241,7 @@ public class BitbucketRepository {
final boolean commitAlreadyBeenProcessed = this.client.hasBuildStatus(
sourceRepository.getOwnerName(), sourceRepository.getRepositoryName(), sourceCommit, buildKeyPart
);
- if (commitAlreadyBeenProcessed) logger.log(Level.INFO,
+ if (commitAlreadyBeenProcessed) logger.log(Level.FINE,
"Commit {0}#{1} has already been processed",
new Object[]{ sourceCommit, buildKeyPart }
);
@@ -257,7 +257,7 @@ public class BitbucketRepository {
String content = comment.getContent();
if (this.isTTPComment(content)) {
rebuildCommentAvailable = true;
- logger.log(Level.INFO,
+ logger.log(Level.FINE,
"Rebuild comment available for commit {0} and comment #{1}",
new Object[]{ sourceCommit, comment.getId() }
);
@@ -270,7 +270,7 @@ public class BitbucketRepository {
if (rebuildCommentAvailable) this.postBuildTagInTTPComment(id, "TTP build flag", buildKeyPart);
final boolean canBuildTarget = rebuildCommentAvailable || !commitAlreadyBeenProcessed;
- logger.log(Level.INFO, "Build target? {0} [rebuild:{1} processed:{2}]", new Object[]{ canBuildTarget, rebuildCommentAvailable, commitAlreadyBeenProcessed});
+ logger.log(Level.FINE, "Build target? {0} [rebuild:{1} processed:{2}]", new Object[]{ canBuildTarget, rebuildCommentAvailable, commitAlreadyBeenProcessed});
return canBuildTarget;
}
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java
index 7ab69c4..cb14908 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java
@@ -61,14 +61,14 @@ public class ApiClient {
ProxyConfiguration proxy = getInstance().proxy;
if (proxy == null) return client;
- logger.log(Level.INFO, "Jenkins proxy: {0}:{1}", new Object[]{ proxy.name, proxy.port });
+ logger.log(Level.FINE, "Jenkins proxy: {0}:{1}", new Object[]{ proxy.name, proxy.port });
client.getHostConfiguration().setProxy(proxy.name, proxy.port);
String username = proxy.getUserName();
String password = proxy.getPassword();
// Consider it to be passed if username specified. Sufficient?
if (username != null && !"".equals(username.trim())) {
- logger.log(Level.INFO, "Using proxy authentication (user={0})", username);
+ logger.log(Level.FINE, "Using proxy authentication (user={0})", username);
client.getState().setProxyCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
}
@@ -155,7 +155,7 @@ public class ApiClient {
new NameValuePair("state", state.toString()),
new NameValuePair("url", buildUrl),
};
- logger.log(Level.INFO, "POST state {0} to {1} with key {2} with response {3}", new Object[]{
+ logger.log(Level.FINE, "POST state {0} to {1} with key {2} with response {3}", new Object[]{
state, url, computedKey, post(url, data)}
);
}