diff --git a/src/main/java/com/gitee/jenkins/trigger/GiteePushTrigger.java b/src/main/java/com/gitee/jenkins/trigger/GiteePushTrigger.java index 9117a6f..1888fe7 100644 --- a/src/main/java/com/gitee/jenkins/trigger/GiteePushTrigger.java +++ b/src/main/java/com/gitee/jenkins/trigger/GiteePushTrigger.java @@ -207,19 +207,20 @@ public class GiteePushTrigger extends Trigger> { } // 兼容构建指令升级 - if (!oldConfig.jobsMigrated3) { + if (!oldConfig.jobsMigrated4) { for (AbstractProject project : Jenkins.getInstance().getAllItems(AbstractProject.class)) { GiteePushTrigger trigger = project.getTrigger(GiteePushTrigger.class); if (trigger != null) { if (trigger.getCiSkip()) { trigger.setBuildInstructionFilterType(BuildInstructionFilterType.CI_SKIP); - } else { + } else if (trigger.getBuildInstructionFilterType() == null) { trigger.setBuildInstructionFilterType(BuildInstructionFilterType.NONE); } project.save(); } } - oldConfig.jobsMigrated3 = true; + oldConfig.jobsMigrated3 = false; + oldConfig.jobsMigrated4 = true; oldConfig.save(); } @@ -610,6 +611,7 @@ public class GiteePushTrigger extends Trigger> { private boolean jobsMigrated = false; private boolean jobsMigrated2 = false; private boolean jobsMigrated3 = false; + private boolean jobsMigrated4 = false; private String GiteeApiToken; private String giteeHostUrl = ""; private boolean ignoreCertificateErrors = false; diff --git a/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java b/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java index f5945ed..4eb48f7 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/note/NoteHookTriggerHandlerImpl.java @@ -85,7 +85,10 @@ class NoteHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler @Override protected boolean isCiSkip(NoteHook hook, BuildInstructionFilter buildInstructionFilter) { - return hook.getPullRequest() == null ? false : !buildInstructionFilter.isBuildAllow(hook.getPullRequest().getBody()); + if (buildInstructionFilter != null && hook.getPullRequest() != null) { + return !buildInstructionFilter.isBuildAllow(hook.getPullRequest().getBody()); + } + return false; } @Override diff --git a/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java b/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java index e1ecc3d..0b0a193 100644 --- a/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java +++ b/src/main/java/com/gitee/jenkins/trigger/handler/pull/PullRequestHookTriggerHandlerImpl.java @@ -116,7 +116,10 @@ class PullRequestHookTriggerHandlerImpl extends AbstractWebHookTriggerHandler @Override protected boolean isCiSkip(PushHook hook, BuildInstructionFilter buildInstructionFilter) { List commits = hook.getCommits(); - if (commits != null && !commits.isEmpty()) { + if (buildInstructionFilter!= null && commits != null && !commits.isEmpty()) { return !buildInstructionFilter.isBuildAllow(commits.get(commits.size() - 1).getMessage()); } return false;