├── .github └── ISSUE_TEMPLATE.adoc ├── .gitignore ├── .idea ├── codeStyleSettings.xml └── encodings.xml ├── .mvn ├── extensions.xml ├── maven.config └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.adoc ├── docs ├── Configuration.adoc ├── FAQ.adoc ├── Features.adoc ├── History.adoc ├── Installation.adoc ├── images │ └── github-project-property.png ├── re-register-hooks.groovy └── re-run-triggers.groovy ├── github-pullrequest-plugin ├── .factorypath ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── com │ │ │ └── github │ │ │ │ └── kostyasha │ │ │ │ └── github │ │ │ │ └── integration │ │ │ │ ├── branch │ │ │ │ ├── AbstractGitHubBranchCause.java │ │ │ │ ├── GitHubBranch.java │ │ │ │ ├── GitHubBranchBadgeAction.java │ │ │ │ ├── GitHubBranchCause.java │ │ │ │ ├── GitHubBranchPollingLogAction.java │ │ │ │ ├── GitHubBranchRepository.java │ │ │ │ ├── GitHubBranchRepositoryFactory.java │ │ │ │ ├── GitHubBranchTrigger.java │ │ │ │ ├── data │ │ │ │ │ └── GitHubBranchEnv.java │ │ │ │ ├── dsl │ │ │ │ │ ├── GitHubBranchJobDslExtenstion.java │ │ │ │ │ └── context │ │ │ │ │ │ ├── GitHubBranchTriggerDslContext.java │ │ │ │ │ │ └── events │ │ │ │ │ │ ├── GitHubBranchCommitChecksDslContext.java │ │ │ │ │ │ ├── GitHubBranchCommitMessageCheckDslContext.java │ │ │ │ │ │ ├── GitHubBranchEventsDslContext.java │ │ │ │ │ │ └── GitHubBranchFilterEventDslContext.java │ │ │ │ ├── events │ │ │ │ │ ├── GitHubBranchEvent.java │ │ │ │ │ ├── GitHubBranchEventDescriptor.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── GitHubBranchCommitEvent.java │ │ │ │ │ │ ├── GitHubBranchCreatedEvent.java │ │ │ │ │ │ ├── GitHubBranchDeletedEvent.java │ │ │ │ │ │ ├── GitHubBranchHashChangedEvent.java │ │ │ │ │ │ ├── GitHubBranchRestrictionFilter.java │ │ │ │ │ │ └── commitchecks │ │ │ │ │ │ ├── GitHubBranchCommitCheck.java │ │ │ │ │ │ ├── GitHubBranchCommitCheckDescriptor.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ └── GitHubBranchCommitMessageCheck.java │ │ │ │ ├── trigger │ │ │ │ │ ├── JobRunnerForBranchCause.java │ │ │ │ │ └── check │ │ │ │ │ │ ├── BranchToCauseConverter.java │ │ │ │ │ │ ├── LocalRepoUpdater.java │ │ │ │ │ │ └── SkipFirstRunForBranchFilter.java │ │ │ │ ├── utils │ │ │ │ │ ├── ItemHelpers.java │ │ │ │ │ └── JobHelper.java │ │ │ │ └── webhook │ │ │ │ │ ├── AbstractGHBranchSubscriber.java │ │ │ │ │ ├── BranchInfo.java │ │ │ │ │ ├── GHBranchSubscriber.java │ │ │ │ │ ├── GitHubBranchRepositoryNameContributor.java │ │ │ │ │ └── WebhookInfoBranchPredicates.java │ │ │ │ ├── generic │ │ │ │ ├── GitHubBadgeAction.java │ │ │ │ ├── GitHubBranchDecisionContext.java │ │ │ │ ├── GitHubCause.java │ │ │ │ ├── GitHubDecisionContext.java │ │ │ │ ├── GitHubEnv.java │ │ │ │ ├── GitHubPRDecisionContext.java │ │ │ │ ├── GitHubPollingLogAction.java │ │ │ │ ├── GitHubRepoEnv.java │ │ │ │ ├── GitHubRepoProvider.java │ │ │ │ ├── GitHubRepository.java │ │ │ │ ├── GitHubRepositoryFactory.java │ │ │ │ ├── GitHubTagDecisionContext.java │ │ │ │ ├── GitHubTrigger.java │ │ │ │ ├── GitHubTriggerDescriptor.java │ │ │ │ ├── dsl │ │ │ │ │ └── repoproviders │ │ │ │ │ │ ├── GHRepoPermissionDslContext.java │ │ │ │ │ │ ├── GitHubPluginRepoProviderDslContext.java │ │ │ │ │ │ └── GitHubRepoProvidersDslContext.java │ │ │ │ ├── errors │ │ │ │ │ ├── GitHubError.java │ │ │ │ │ ├── GitHubErrorsAction.java │ │ │ │ │ └── impl │ │ │ │ │ │ ├── GitHubHookRegistrationError.java │ │ │ │ │ │ └── GitHubRepoProviderError.java │ │ │ │ ├── repoprovider │ │ │ │ │ ├── GHPermission.java │ │ │ │ │ └── GitHubPluginRepoProvider.java │ │ │ │ └── utils │ │ │ │ │ └── RetryableGitHubOperation.java │ │ │ │ ├── multibranch │ │ │ │ ├── Functions.java │ │ │ │ ├── GitHubBranchBuildStrategy.java │ │ │ │ ├── GitHubParametersAction.java │ │ │ │ ├── GitHubSCMSource.java │ │ │ │ ├── LocalRepoPlunger.java │ │ │ │ ├── action │ │ │ │ │ ├── GitHubBranchAction.java │ │ │ │ │ ├── GitHubLinkAction.java │ │ │ │ │ ├── GitHubPRAction.java │ │ │ │ │ ├── GitHubRepo.java │ │ │ │ │ ├── GitHubRepoAction.java │ │ │ │ │ ├── GitHubSCMSourcesLocalStorage.java │ │ │ │ │ └── GitHubTagAction.java │ │ │ │ ├── category │ │ │ │ │ ├── GitHubBranchSCMHeadCategory.java │ │ │ │ │ ├── GitHubPRSCMHeadCategory.java │ │ │ │ │ ├── GitHubSCMHeadCategory.java │ │ │ │ │ └── GitHubTagSCMHeadCategory.java │ │ │ │ ├── fs │ │ │ │ │ ├── GitHubSCMFile.java │ │ │ │ │ ├── GitHubSCMFileSystem.java │ │ │ │ │ ├── GitHubSCMFileSystemBuilder.java │ │ │ │ │ ├── GitHubSCMProbe.java │ │ │ │ │ └── TreeCache.java │ │ │ │ ├── handler │ │ │ │ │ ├── GitHubBranchHandler.java │ │ │ │ │ ├── GitHubHandler.java │ │ │ │ │ ├── GitHubHandlerDescriptor.java │ │ │ │ │ ├── GitHubPRHandler.java │ │ │ │ │ ├── GitHubSourceContext.java │ │ │ │ │ └── GitHubTagHandler.java │ │ │ │ ├── head │ │ │ │ │ ├── GitHubBranchSCMHead.java │ │ │ │ │ ├── GitHubPRSCMHead.java │ │ │ │ │ ├── GitHubSCMHead.java │ │ │ │ │ └── GitHubTagSCMHead.java │ │ │ │ ├── hooks │ │ │ │ │ ├── GHMultiBranchSubscriber.java │ │ │ │ │ ├── GHPRMultiBranchSubscriber.java │ │ │ │ │ ├── GitHubBranchSCMHeadEvent.java │ │ │ │ │ ├── GitHubPullRequestScmHeadEvent.java │ │ │ │ │ ├── GitHubScmHeadEvent.java │ │ │ │ │ ├── GitHubScmSourceRepositoryNameContributor.java │ │ │ │ │ └── GitHubTagSCMHeadEvent.java │ │ │ │ ├── repoprovider │ │ │ │ │ ├── GitHubPluginRepoProvider2.java │ │ │ │ │ ├── GitHubRepoProvider2.java │ │ │ │ │ └── GitHubRepoProviderDescriptor2.java │ │ │ │ ├── revision │ │ │ │ │ └── GitHubSCMRevision.java │ │ │ │ └── scm │ │ │ │ │ ├── AsIsGitSCMFactory.java │ │ │ │ │ ├── GitHubSCMFactory.java │ │ │ │ │ ├── NoGitHubSCMFactory.java │ │ │ │ │ └── NoGitSCM.java │ │ │ │ └── tag │ │ │ │ ├── GitHubTag.java │ │ │ │ ├── GitHubTagCause.java │ │ │ │ ├── GitHubTagEnv.java │ │ │ │ ├── GitHubTagRepository.java │ │ │ │ ├── LocalRepoUpdater.java │ │ │ │ ├── TagToCauseConverter.java │ │ │ │ └── events │ │ │ │ ├── GitHubTagEvent.java │ │ │ │ ├── GitHubTagEventDescriptor.java │ │ │ │ └── impl │ │ │ │ ├── GitHubTagCreatedEvent.java │ │ │ │ └── GitHubTagRestrictionFilter.java │ │ └── org │ │ │ └── jenkinsci │ │ │ └── plugins │ │ │ └── github │ │ │ └── pullrequest │ │ │ ├── GitHubPRBadgeAction.java │ │ │ ├── GitHubPRBuildChooser.java │ │ │ ├── GitHubPRBuildListener.java │ │ │ ├── GitHubPRCause.java │ │ │ ├── GitHubPRLabel.java │ │ │ ├── GitHubPRMessage.java │ │ │ ├── GitHubPRPollingLogAction.java │ │ │ ├── GitHubPRPullRequest.java │ │ │ ├── GitHubPRRepository.java │ │ │ ├── GitHubPRRepositoryFactory.java │ │ │ ├── GitHubPRTrigger.java │ │ │ ├── GitHubPRTriggerMode.java │ │ │ ├── builders │ │ │ └── GitHubPRStatusBuilder.java │ │ │ ├── data │ │ │ └── GitHubPREnv.java │ │ │ ├── dsl │ │ │ ├── GitHubPRJobDslExtension.java │ │ │ └── context │ │ │ │ ├── GitHubPRTriggerDslContext.java │ │ │ │ ├── GitHubPRTriggerModeDslContext.java │ │ │ │ ├── events │ │ │ │ └── GitHubPREventsDslContext.java │ │ │ │ ├── publishers │ │ │ │ ├── GitHubCommentPublisherDslContext.java │ │ │ │ └── GitHubPRStatusPublisherDslContext.java │ │ │ │ └── steps │ │ │ │ └── GitHubPRStatusStepDslContext.java │ │ │ ├── events │ │ │ ├── GitHubPREvent.java │ │ │ ├── GitHubPREventDescriptor.java │ │ │ └── impl │ │ │ │ ├── GitHubPRCloseEvent.java │ │ │ │ ├── GitHubPRCommentEvent.java │ │ │ │ ├── GitHubPRCommitEvent.java │ │ │ │ ├── GitHubPRDescriptionEvent.java │ │ │ │ ├── GitHubPRLabelAddedEvent.java │ │ │ │ ├── GitHubPRLabelExistsEvent.java │ │ │ │ ├── GitHubPRLabelNotExistsEvent.java │ │ │ │ ├── GitHubPRLabelPatternExistsEvent.java │ │ │ │ ├── GitHubPRLabelRemovedEvent.java │ │ │ │ ├── GitHubPRNonMergeableEvent.java │ │ │ │ ├── GitHubPRNumber.java │ │ │ │ └── GitHubPROpenEvent.java │ │ │ ├── extra │ │ │ └── GitHubPRLabelUnblockQueueCondition.java │ │ │ ├── pipeline │ │ │ ├── SetCommitStatusExecution.java │ │ │ └── SetCommitStatusStep.java │ │ │ ├── publishers │ │ │ ├── GitHubPRAbstractPublisher.java │ │ │ └── impl │ │ │ │ ├── GitHubPRBuildStatusPublisher.java │ │ │ │ ├── GitHubPRClosePublisher.java │ │ │ │ ├── GitHubPRCommentPublisher.java │ │ │ │ ├── GitHubPRLabelAddPublisher.java │ │ │ │ └── GitHubPRLabelRemovePublisher.java │ │ │ ├── restrictions │ │ │ ├── GitHubPRBranchRestriction.java │ │ │ └── GitHubPRUserRestriction.java │ │ │ ├── trigger │ │ │ ├── JobRunnerForCause.java │ │ │ ├── NewPRInterruptCause.java │ │ │ └── check │ │ │ │ ├── BranchRestrictionFilter.java │ │ │ │ ├── LocalRepoUpdater.java │ │ │ │ ├── NotUpdatedPRFilter.java │ │ │ │ ├── PullRequestToCauseConverter.java │ │ │ │ ├── SkipFirstRunForPRFilter.java │ │ │ │ ├── SkipPRInBadState.java │ │ │ │ ├── SkippedCauseFilter.java │ │ │ │ └── UserRestrictionFilter.java │ │ │ ├── utils │ │ │ ├── IOUtils.java │ │ │ ├── JobHelper.java │ │ │ ├── LoggingTaskListenerWrapper.java │ │ │ ├── PRHelperFunctions.java │ │ │ ├── PublisherErrorHandler.java │ │ │ └── StatusVerifier.java │ │ │ └── webhook │ │ │ ├── AbstractGHPullRequestSubsriber.java │ │ │ ├── GHPullRequestSubscriber.java │ │ │ ├── GitHubPRRepositoryNameContributor.java │ │ │ ├── PullRequestInfo.java │ │ │ └── WebhookInfoPredicates.java │ ├── resources │ │ ├── com │ │ │ └── github │ │ │ │ └── kostyasha │ │ │ │ └── github │ │ │ │ └── integration │ │ │ │ ├── branch │ │ │ │ ├── GitHubBranch │ │ │ │ │ └── index.groovy │ │ │ │ ├── GitHubBranchBadgeAction │ │ │ │ │ └── badge.groovy │ │ │ │ ├── GitHubBranchCause │ │ │ │ │ └── description.groovy │ │ │ │ ├── GitHubBranchPollingLogAction │ │ │ │ │ └── index.groovy │ │ │ │ ├── GitHubBranchRepository │ │ │ │ │ └── index.groovy │ │ │ │ ├── GitHubBranchTrigger │ │ │ │ │ ├── config.groovy │ │ │ │ │ ├── help-abortRunning.html │ │ │ │ │ ├── help-events.html │ │ │ │ │ ├── help-skipFirstRun.html │ │ │ │ │ └── help-triggerMode.html │ │ │ │ └── events │ │ │ │ │ └── impl │ │ │ │ │ ├── GitHubBranchCommitEvent │ │ │ │ │ └── config.groovy │ │ │ │ │ ├── GitHubBranchCreatedEvent │ │ │ │ │ └── config.groovy │ │ │ │ │ ├── GitHubBranchRestrictionFilter │ │ │ │ │ └── config.groovy │ │ │ │ │ └── commitchecks │ │ │ │ │ └── impl │ │ │ │ │ └── GitHubBranchCommitMessageCheck │ │ │ │ │ ├── config.groovy │ │ │ │ │ ├── help-matchCriteria.html │ │ │ │ │ └── help.html │ │ │ │ ├── generic │ │ │ │ ├── errors │ │ │ │ │ └── GitHubErrorsAction │ │ │ │ │ │ └── jobMain.groovy │ │ │ │ └── repoprovider │ │ │ │ │ └── GitHubPluginRepoProvider │ │ │ │ │ ├── config.groovy │ │ │ │ │ ├── help-cacheConnection.html │ │ │ │ │ ├── help-manageHooks.html │ │ │ │ │ └── help-repoPermission.html │ │ │ │ ├── multibranch │ │ │ │ ├── GitHubBranchBuildStrategy │ │ │ │ │ ├── config.groovy │ │ │ │ │ └── help.html │ │ │ │ ├── GitHubSCMSource │ │ │ │ │ └── config.groovy │ │ │ │ ├── action │ │ │ │ │ └── GitHubSCMSourcesReposAction │ │ │ │ │ │ └── index.groovy │ │ │ │ ├── handler │ │ │ │ │ ├── GitHubBranchHandler │ │ │ │ │ │ └── config.groovy │ │ │ │ │ ├── GitHubPRHandler │ │ │ │ │ │ └── config.groovy │ │ │ │ │ └── GitHubTagHandler │ │ │ │ │ │ └── config.groovy │ │ │ │ ├── repoprovider │ │ │ │ │ └── GitHubPluginRepoProvider2 │ │ │ │ │ │ └── config.groovy │ │ │ │ └── scm │ │ │ │ │ └── AsIsGitSCMFactory │ │ │ │ │ └── config.groovy │ │ │ │ └── tag │ │ │ │ ├── GitHubTag │ │ │ │ └── index.groovy │ │ │ │ ├── GitHubTagCause │ │ │ │ └── description.groovy │ │ │ │ └── events │ │ │ │ └── impl │ │ │ │ ├── GitHubTagCreatedEvent │ │ │ │ └── config.groovy │ │ │ │ └── GitHubTagRestrictionFilter │ │ │ │ └── config.groovy │ │ ├── index.jelly │ │ └── org │ │ │ └── jenkinsci │ │ │ └── plugins │ │ │ └── github │ │ │ └── pullrequest │ │ │ ├── GitHubPRBadgeAction │ │ │ └── badge.groovy │ │ │ ├── GitHubPRBuildChooser │ │ │ ├── config.groovy │ │ │ └── help.html │ │ │ ├── GitHubPRCause │ │ │ └── description.groovy │ │ │ ├── GitHubPRLabel │ │ │ ├── config.groovy │ │ │ ├── help-labels.html │ │ │ └── help.html │ │ │ ├── GitHubPRMessage │ │ │ ├── config.groovy │ │ │ └── help-content.html │ │ │ ├── GitHubPRPollingLogAction │ │ │ └── index.groovy │ │ │ ├── GitHubPRPullRequest │ │ │ └── index.groovy │ │ │ ├── GitHubPRRepository │ │ │ └── index.groovy │ │ │ ├── GitHubPRTrigger │ │ │ ├── config.groovy │ │ │ ├── global.groovy │ │ │ ├── help-abortRunning.html │ │ │ ├── help-branchRestriction.html │ │ │ ├── help-cacheSize.html │ │ │ ├── help-cancelQueued.html │ │ │ ├── help-events.html │ │ │ ├── help-preStatus.html │ │ │ ├── help-skipFirstRun.html │ │ │ ├── help-triggerMode.html │ │ │ ├── help-useGitHubHooks.html │ │ │ ├── help-userRestriction.html │ │ │ └── help.html │ │ │ ├── builders │ │ │ └── GitHubPRStatusBuilder │ │ │ │ └── config.groovy │ │ │ ├── events │ │ │ └── impl │ │ │ │ ├── GitHubPRCloseEvent │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRCommentEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRCommitEvent │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRDescriptionEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRLabelAddedEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRLabelExistsEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRLabelNotExistsEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRLabelPatternExistsEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRLabelRemovedEvent │ │ │ │ ├── config.groovy │ │ │ │ └── help.html │ │ │ │ ├── GitHubPRNonMergeableEvent │ │ │ │ └── config.groovy │ │ │ │ ├── GitHubPRNumber │ │ │ │ ├── config.groovy │ │ │ │ ├── help-match.html │ │ │ │ ├── help-number.html │ │ │ │ └── help-skip.html │ │ │ │ └── GitHubPROpenEvent │ │ │ │ └── help.html │ │ │ ├── extra │ │ │ └── GitHubPRLabelUnblockQueueCondition │ │ │ │ └── config.groovy │ │ │ ├── pipeline │ │ │ └── SetCommitStatusStep │ │ │ │ ├── config.groovy │ │ │ │ ├── help-context.html │ │ │ │ ├── help-message.html │ │ │ │ ├── help-state.html │ │ │ │ └── help.html │ │ │ ├── publishers │ │ │ └── impl │ │ │ │ ├── GitHubPRBuildStatusPublisher │ │ │ │ ├── BuildMessage │ │ │ │ │ └── config.groovy │ │ │ │ ├── config.groovy │ │ │ │ └── help-statusMsg.html │ │ │ │ ├── GitHubPRClosePublisher │ │ │ │ └── config.groovy │ │ │ │ ├── GitHubPRCommentPublisher │ │ │ │ └── config.groovy │ │ │ │ ├── GitHubPRLabelAddPublisher │ │ │ │ └── config.groovy │ │ │ │ └── GitHubPRLabelRemovePublisher │ │ │ │ └── config.groovy │ │ │ ├── restrictions │ │ │ ├── GitHubPRBranchRestriction │ │ │ │ └── config.groovy │ │ │ └── GitHubPRUserRestriction │ │ │ │ └── config.groovy │ │ │ └── utils │ │ │ ├── PublisherErrorHandler │ │ │ └── config.groovy │ │ │ └── StatusVerifier │ │ │ └── config.groovy │ └── webapp │ │ ├── git-branch.svg │ │ ├── git-pull-request.svg │ │ ├── git-tag.svg │ │ └── scripts │ │ └── featureButton.js │ └── test │ ├── java │ ├── com │ │ └── github │ │ │ └── kostyasha │ │ │ └── github │ │ │ └── integration │ │ │ ├── branch │ │ │ ├── GitHubBranchTriggerJRuleTest.java │ │ │ ├── GitHubBranchTriggerTest.java │ │ │ ├── events │ │ │ │ └── impl │ │ │ │ │ ├── GitHubBranchCommitEventTest.java │ │ │ │ │ ├── GitHubBranchCreatedEventTest.java │ │ │ │ │ ├── GitHubBranchDeletedEventTest.java │ │ │ │ │ ├── GitHubBranchHashChangedEventTest.java │ │ │ │ │ ├── GitHubBranchRestrictionFilterTest.java │ │ │ │ │ └── commitchecks │ │ │ │ │ └── impl │ │ │ │ │ └── GitHubBranchCommitMessageCheckTest.java │ │ │ ├── its │ │ │ │ ├── BranchITest.java │ │ │ │ └── GitHubBranchTriggerITest.java │ │ │ ├── test │ │ │ │ ├── GHMockRule.java │ │ │ │ └── InjectJenkinsMembersRule.java │ │ │ ├── trigger │ │ │ │ └── check │ │ │ │ │ ├── BranchToCauseConverterTest.java │ │ │ │ │ └── LocalRepoUpdaterTest.java │ │ │ └── webhook │ │ │ │ └── GHBranchSubscriberTest.java │ │ │ └── generic │ │ │ └── utils │ │ │ └── RetryableGitHubOperationTest.java │ └── org │ │ └── jenkinsci │ │ └── plugins │ │ ├── github │ │ └── pullrequest │ │ │ ├── GitHubPRRepositoryFactoryTest.java │ │ │ ├── GitHubPRRepositoryTest.java │ │ │ ├── GitHubPRTriggerJRuleTest.java │ │ │ ├── GitHubPRTriggerMockTest.java │ │ │ ├── GitHubPRTriggerTest.java │ │ │ ├── builders │ │ │ └── GitHubPRStatusBuilderTest.java │ │ │ ├── data │ │ │ └── GitHubPREnvTest.java │ │ │ ├── dsl │ │ │ ├── DslIntegrationTest.java │ │ │ ├── GitHubPRJobDslExtensionTest.java │ │ │ └── context │ │ │ │ └── publishers │ │ │ │ └── GitHubCommentPublisherDslContextTest.java │ │ │ ├── events │ │ │ └── impl │ │ │ │ ├── GitHubPRCommentEventTest.java │ │ │ │ ├── GitHubPRDescriptionEventTest.java │ │ │ │ ├── GitHubPRLabelAddedEventTest.java │ │ │ │ ├── GitHubPRLabelExistsEventTest.java │ │ │ │ ├── GitHubPRLabelNotExistsEventTest.java │ │ │ │ ├── GitHubPRLabelRemovedEventTest.java │ │ │ │ ├── GitHubPRNonMergeableEventTest.java │ │ │ │ └── GitHubPRNumberTest.java │ │ │ ├── trigger │ │ │ ├── AbortRunningJobRunnerCauseTest.java │ │ │ ├── CancelQueuedJobRunnerForCauseTest.java │ │ │ ├── JobRunnerForCauseTest.java │ │ │ └── check │ │ │ │ ├── BranchRestrictionFilterTest.java │ │ │ │ ├── LocalRepoUpdaterTest.java │ │ │ │ ├── NotUpdatedPRFilterTest.java │ │ │ │ ├── PullRequestToCauseConverterTest.java │ │ │ │ ├── SkipFirstRunForPRFilterTest.java │ │ │ │ ├── SkipPRInBadStateTest.java │ │ │ │ ├── SkippedCauseFilterTest.java │ │ │ │ └── UserRestrictionFilterTest.java │ │ │ ├── util │ │ │ ├── TaskListenerWrapperRule.java │ │ │ └── TestUtil.java │ │ │ └── webhook │ │ │ └── GHPullRequestSubscriberTest.java │ │ └── github_integration │ │ ├── awaitility │ │ ├── GHBranchAppeared.java │ │ ├── GHFromServerConfigAppeared.java │ │ ├── GHPRAppeared.java │ │ ├── GHRepoAppeared.java │ │ ├── GHRepoDeleted.java │ │ └── GHTriggerRunAndEnd.java │ │ ├── hamcrest │ │ └── CommitStatusMatcher.java │ │ ├── its │ │ ├── AbstractPRTest.java │ │ ├── FreestyleITest.java │ │ ├── MatrixProjectITest.java │ │ ├── WorkflowFailTest.java │ │ └── WorkflowITest.java │ │ └── junit │ │ └── GHRule.java │ └── resources │ ├── checkstyle │ ├── checkstyle-suppressions.xml │ └── checkstyle.xml │ ├── com │ └── github │ │ └── kostyasha │ │ └── github │ │ └── integration │ │ └── branch │ │ ├── GitHubBranchTriggerTest │ │ ├── actualiseRepo │ │ │ ├── config.xml │ │ │ └── jobs │ │ │ │ └── project │ │ │ │ ├── com.github.kostyasha.github.integration.branch.GitHubBranchRepository.runtime.xml │ │ │ │ └── config.xml │ │ ├── buildButtonsPerms │ │ │ ├── config.xml │ │ │ └── jobs │ │ │ │ └── project │ │ │ │ ├── com.github.kostyasha.github.integration.branch.GitHubBranchRepository.runtime.xml │ │ │ │ └── config.xml │ │ └── someTest │ │ │ ├── config.xml │ │ │ └── jobs │ │ │ └── project │ │ │ └── com.github.kostyasha.github.integration.branch.GitHubBranchRepository.runtime.xml │ │ └── test │ │ └── GHMockRule │ │ ├── branch-should-change.json │ │ ├── comments1.json │ │ ├── issues1.json │ │ ├── org-repo-branches.json │ │ ├── pulls.json │ │ ├── repos-repo.json │ │ └── user.json │ ├── dsl │ ├── branch-jobdsl.groovy │ └── jobdsl.groovy │ ├── invalidConfig │ └── org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml │ ├── logback.groovy_ │ ├── logback.xml │ ├── org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml │ ├── org │ └── jenkinsci │ │ └── plugins │ │ ├── github │ │ └── pullrequest │ │ │ ├── GitHubPRTriggerMockTest │ │ │ ├── actualiseRepo │ │ │ │ ├── config.xml │ │ │ │ └── jobs │ │ │ │ │ └── project │ │ │ │ │ ├── config.xml │ │ │ │ │ └── org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml │ │ │ └── badStatePR │ │ │ │ ├── config.xml │ │ │ │ └── jobs │ │ │ │ └── test-job │ │ │ │ ├── config.xml │ │ │ │ └── org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml │ │ │ └── GitHubPRTriggerTest │ │ │ ├── buildButtonsPerms │ │ │ └── jobs │ │ │ │ └── project │ │ │ │ ├── config.xml │ │ │ │ └── org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml │ │ │ └── ensureOldValid │ │ │ └── jobs │ │ │ └── test-job │ │ │ ├── config.xml │ │ │ └── org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml │ │ └── github_integration │ │ └── its │ │ └── WorkflowITest │ │ ├── testContextStatuses.groovy │ │ └── workflowTest.groovy │ └── payload │ ├── issue_comment.json │ ├── pull_request-labelled.json │ └── pull_request.json ├── mvnw ├── mvnw.cmd ├── pom.xml └── travis.sh /.github/ISSUE_TEMPLATE.adoc: -------------------------------------------------------------------------------- 1 | ## Before creating issue 2 | 3 | - Search for existing github issue 4 | 5 | ## For creating new issue 6 | 7 | - Check that you didn't miss documentation https://github.com/KostyaSha/github-integration-plugin/tree/master/docs 8 | - Check that you correctly configure `github-plugin` in global settings. 9 | - Check that you sepcified `GitHub project` job property. 10 | - Post piece or the whole `config.xml` using GitHub markdown syntax. Describe what job type do you use. 11 | - Post `GitHub XXX Polling Log` action on left side of job or from triggered build 12 | - If you are using some advanced jenkins configuration handler describe it. 13 | - Check for logs in global settings jenkins system log. 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## rebel 2 | github-pullrequest-plugin/src/main/resources/rebel.xml 3 | 4 | ### Jenkins hpi:run 5 | work 6 | 7 | ### Maven.gitignore 8 | target/ 9 | #pom.xml.tag 10 | #pom.xml.releaseBackup 11 | #pom.xml.versionsBackup 12 | #pom.xml.next 13 | #release.properties 14 | 15 | ### Global/JetBrains.gitignore 16 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 17 | *.iml 18 | 19 | ## Directory-based project format: 20 | .idea/* 21 | !.idea/codeStyleSettings.xml 22 | !.idea/encodings.xml 23 | 24 | ## File-based project format: 25 | *.ipr 26 | *.iws 27 | 28 | ## Plugin-specific files: 29 | 30 | # IntelliJ 31 | out/ 32 | 33 | # mpeltonen/sbt-idea plugin 34 | .idea_modules/ 35 | 36 | # JIRA plugin 37 | atlassian-ide-plugin.xml 38 | 39 | # Crashlytics plugin (for Android Studio and IntelliJ) 40 | com_crashlytics_export_strings.xml 41 | crashlytics.properties 42 | crashlytics-build.properties 43 | 44 | ### Global/Eclipse.gitignore 45 | *.pydevproject 46 | .metadata 47 | .gradle 48 | bin/ 49 | tmp/ 50 | *.tmp 51 | *.bak 52 | *.swp 53 | *~.nib 54 | local.properties 55 | .settings/ 56 | .loadpath 57 | 58 | # Eclipse Core 59 | .project 60 | 61 | # External tool builders 62 | .externalToolBuilders/ 63 | 64 | # Locally stored "Eclipse launch configurations" 65 | *.launch 66 | 67 | # CDT-specific 68 | .cproject 69 | 70 | # JDT-specific (Eclipse Java Development Tools) 71 | .classpath 72 | 73 | # PDT-specific 74 | .buildpath 75 | 76 | # sbteclipse plugin 77 | .target 78 | 79 | # TeXlipse plugin 80 | .texlipse 81 | 82 | ### Global/Vim.gitignore 83 | [._]*.s[a-w][a-z] 84 | [._]s[a-w][a-z] 85 | *.un~ 86 | Session.vim 87 | .netrwhist 88 | *~ 89 | some/ 90 | -------------------------------------------------------------------------------- /.idea/codeStyleSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 15 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.mvn/extensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | io.jenkins.tools.incrementals 4 | git-changelist-maven-extension 5 | 1.6 6 | 7 | 8 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | -Pconsume-incrementals 2 | -Pmight-produce-incrementals 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KostyaSha/github-integration-plugin/50adabf6a628fd03c532224a187221899d8d1930/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.8/apache-maven-3.8.8-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | #sudo: required 2 | dist: trusty 3 | language: java 4 | jdk: oraclejdk8 5 | #addons: 6 | # apt: 7 | # packages: 8 | # - oracle-java8-installer 9 | before_install: 10 | - pip install --user codecov 11 | after_success: 12 | - codecov 13 | after_failure: 14 | - pwd 15 | - cat /home/travis/build/KostyaSha/github-integration-plugin/github-pullrequest-plugin/target/surefire-reports/*.txt 16 | install: true 17 | script: ./travis.sh 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kanstantsin Shautsou , EPAM Systems 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = GitHub Integration Plugin 2 | 3 | image:https://img.shields.io/badge/java-1.8-yellow.svg["Minimal java version"] 4 | //image:https://scan.coverity.com/projects/XXXX/badge.svg?flat=1["Coverity Scan Build Status", link="https://scan.coverity.com/projects/XXXX"] 5 | image:https://travis-ci.org/KostyaSha/github-integration-plugin.svg?branch=master["Build Status", link="https://travis-ci.org/KostyaSha/github-integration-plugin"] 6 | image:https://codecov.io/github/KostyaSha/github-integration-plugin/coverage.svg?branch=master["codecov.io", link="https://codecov.io/github/KostyaSha/github-integration-plugin/?branch=master"] 7 | image:https://jitpack.io/v/KostyaSha/github-integration-plugin.svg[Release,link="https://jitpack.io/#KostyaSha/github-integration-plugin"] 8 | 9 | Provides `GitHub Pull Request` and `GitHub Branch` triggers 10 | 11 | == Documentation 12 | 13 | link:/docs[docs subdirectory] 14 | 15 | == Version history 16 | 17 | Please refer to link:/CHANGELOG.md[the changelog]. 18 | 19 | == Disclaimer 20 | 21 | * Backward compatibility may be broken in any time. (But wasn't in the last year and kept when it possible) 22 | -------------------------------------------------------------------------------- /docs/FAQ.adoc: -------------------------------------------------------------------------------- 1 | == FAQ 2 | 3 | ==== Environment variables disappeared for triggered build! 4 | 5 | Set `-Dhudson.model.ParametersAction.keepUndefinedParameters=true` for jenkins java process. Caused by "ugly" `SECURITY-170` fix. 6 | UPD workarounded in latest versions. 7 | 8 | ==== Option `Pipeline script from SCM` doesn't work 9 | 10 | Please see https://github.com/KostyaSha/github-integration-plugin/issues/60#issuecomment-200060734 11 | Example of workaround: https://gist.github.com/kad/4a5a8f669d4a4090b43be1f1c5461df3 12 | 13 | ==== Jenkins doesn't see changes in githhub (i.e. builds not triggered when hook received) 14 | 15 | Set `GitHub client cache size (MB)` in Jenkins system configuration to `0`. 16 | Please see https://github.com/KostyaSha/github-integration-plugin/issues/244 for more details. 17 | -------------------------------------------------------------------------------- /docs/History.adoc: -------------------------------------------------------------------------------- 1 | This was started as rewritten version of https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin[ghprb-plugin] 2 | that after many years was in complex code state when keeping backward compatibility with fixing all bugs almost 3 | impossible and makes no sense (IMHO). 4 | Code was inspired by github-plugin, git-plugin, ghprb-plugin and others. 5 | Other GitHub related features will be made as part of future github-integration-plugin that should also include github-pullrequest-plugin. 6 | PR plugin is separate to keep backward compatibility for those who already using it. Experimental features will be in some experimental submodule. -------------------------------------------------------------------------------- /docs/Installation.adoc: -------------------------------------------------------------------------------- 1 | == Installation 2 | 3 | * Default (main) Update Center from jenkins installation. 4 | * Experimental releases are in https://jenkins-ci.org/content/experimental-plugins-update-center/[Experimental Update Center]. 5 | Which is also the preferred way of installation. 6 | * If you don't want to change your Update Center, you can the download the `.hpi` from a mirror 7 | http://mirrors.jenkins-ci.org/plugins/github-pullrequest/ and upload it to Jenkins Plugin Manager. 8 | -------------------------------------------------------------------------------- /docs/images/github-project-property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KostyaSha/github-integration-plugin/50adabf6a628fd03c532224a187221899d8d1930/docs/images/github-project-property.png -------------------------------------------------------------------------------- /docs/re-register-hooks.groovy: -------------------------------------------------------------------------------- 1 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghPRTriggerFromJob 2 | import static com.github.kostyasha.github.integration.branch.utils.JobHelper.ghBranchTriggerFromJob 3 | 4 | import com.github.kostyasha.github.integration.branch.GitHubBranchTrigger 5 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger 6 | 7 | Jenkins.instance.getAllItems(Job.class).each{ job -> 8 | GitHubPRTrigger prTrigger = ghPRTriggerFromJob(job) 9 | if (prTrigger != null) { 10 | println "Starting GH PR trigger for " + job.getFullName() 11 | try { 12 | prTrigger.start(job, true) 13 | } catch (Throwable error) { 14 | println "ERROR: failed to start branch trigger for " + job.getFullName() 15 | print error 16 | } 17 | } 18 | 19 | GitHubBranchTrigger branchTrigger = ghBranchTriggerFromJob(job) 20 | if (branchTrigger != null) { 21 | println "Starting GH Branch trigger for " + job.getFullName() 22 | try { 23 | branchTrigger.start(job, true) 24 | } catch (Throwable error) { 25 | println "ERROR: failed to start branch trigger for " + job.getFullName() 26 | print error 27 | 28 | } 29 | } 30 | } 31 | println "" 32 | -------------------------------------------------------------------------------- /docs/re-run-triggers.groovy: -------------------------------------------------------------------------------- 1 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghPRTriggerFromJob 2 | import static com.github.kostyasha.github.integration.branch.utils.JobHelper.ghBranchTriggerFromJob 3 | 4 | import com.github.kostyasha.github.integration.branch.GitHubBranchTrigger 5 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger 6 | 7 | Jenkins.instance.getAllItems(Job.class).each{ job -> 8 | GitHubPRTrigger prTrigger = ghPRTriggerFromJob(job) 9 | if (prTrigger != null) { 10 | println "Running GH PR trigger for " + job.getFullName() 11 | try { 12 | prTrigger.run() 13 | } catch (Throwable error) { 14 | println "ERROR: failed to run branch trigger for " + job.getFullName() 15 | print error 16 | } 17 | } 18 | 19 | GitHubBranchTrigger branchTrigger = ghBranchTriggerFromJob(job) 20 | if (branchTrigger != null) { 21 | println "Running GH Branch trigger for " + job.getFullName() 22 | try { 23 | branchTrigger.run() 24 | } catch (Throwable error) { 25 | println "ERROR: failed to run branch trigger for " + job.getFullName() 26 | print error 27 | 28 | } 29 | } 30 | } 31 | println "" 32 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/AbstractGitHubBranchCause.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubCause; 4 | 5 | import edu.umd.cs.findbugs.annotations.CheckForNull; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public abstract class AbstractGitHubBranchCause> extends GitHubCause { 11 | 12 | /** 13 | * null for deleted branch/tag 14 | */ 15 | @CheckForNull 16 | private final String commitSha; 17 | 18 | @CheckForNull 19 | private final String fullRef; 20 | 21 | protected AbstractGitHubBranchCause(String commitSha, String fullRef) { 22 | this.commitSha = commitSha; 23 | this.fullRef = fullRef; 24 | } 25 | 26 | /** 27 | * Copy constructor 28 | */ 29 | protected AbstractGitHubBranchCause(AbstractGitHubBranchCause cause) { 30 | this(cause.getCommitSha(), cause.getFullRef()); 31 | withGitUrl(cause.getGitUrl()); 32 | withSshUrl(cause.getSshUrl()); 33 | withHtmlUrl(cause.getHtmlUrl()); 34 | withPollingLog(cause.getPollingLog()); 35 | withReason(cause.getReason()); 36 | withSkip(cause.isSkip()); 37 | withTitle(cause.getTitle()); 38 | } 39 | 40 | @CheckForNull 41 | public String getCommitSha() { 42 | return commitSha; 43 | } 44 | 45 | @CheckForNull 46 | public String getFullRef() { 47 | return fullRef; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/GitHubBranch.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch; 2 | 3 | import hudson.Functions; 4 | import org.kohsuke.github.GHBranch; 5 | import org.kohsuke.github.GHRepository; 6 | 7 | /** 8 | * Store local information about branch. 9 | * 10 | * @author Kanstantsin Shautsou 11 | * @see GitHubBranchRepository 12 | */ 13 | public class GitHubBranch { 14 | 15 | private String name; 16 | private String commitSha; 17 | private String htmlUrl; 18 | 19 | public GitHubBranch(GHBranch ghBranch) { 20 | this(ghBranch.getName(), ghBranch.getSHA1(), ghBranch.getOwner()); 21 | } 22 | 23 | public GitHubBranch(String name, String commitSha, GHRepository ghRepository) { 24 | this.name = name; 25 | this.commitSha = commitSha; 26 | this.htmlUrl = ghRepository.getHtmlUrl().toString() + "/tree/" + name; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getCommitSha() { 38 | return commitSha; 39 | } 40 | 41 | public void setCommitSha(String sha1) { 42 | this.commitSha = sha1; 43 | } 44 | 45 | public String getHtmlUrl() { 46 | return htmlUrl; 47 | } 48 | 49 | public void setHtmlUrl(String htmlUrl) { 50 | this.htmlUrl = htmlUrl; 51 | } 52 | 53 | public static String getIconFileName() { 54 | return Functions.getResourcePath() + "/plugin/github-pullrequest/git-branch.svg"; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/GitHubBranchBadgeAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubBadgeAction; 4 | 5 | /** 6 | * @author Kanstantsin Shautsou 7 | */ 8 | public class GitHubBranchBadgeAction extends GitHubBadgeAction { 9 | 10 | private String branchName; 11 | 12 | public GitHubBranchBadgeAction(GitHubBranchCause cause) { 13 | super(cause); 14 | this.branchName = cause.getBranchName(); 15 | } 16 | 17 | public String getBranchName() { 18 | return branchName; 19 | } 20 | 21 | @Override 22 | public String getIconFileName() { 23 | return null; 24 | } 25 | 26 | @Override 27 | public String getDisplayName() { 28 | return null; 29 | } 30 | 31 | @Override 32 | public String getUrlName() { 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/GitHubBranchPollingLogAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubPollingLogAction; 4 | import hudson.model.Job; 5 | import hudson.model.Run; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public class GitHubBranchPollingLogAction extends GitHubPollingLogAction { 11 | public GitHubBranchPollingLogAction(Job job) { 12 | super(job); 13 | } 14 | 15 | public GitHubBranchPollingLogAction(Run run) { 16 | super(run); 17 | } 18 | 19 | public String getPollingFileName() { 20 | return "github-branch-polling.log"; 21 | } 22 | 23 | @Override 24 | public String getIconFileName() { 25 | return "clipboard.png"; 26 | } 27 | 28 | @Override 29 | public String getDisplayName() { 30 | return "GitHub Branch Polling Log"; 31 | } 32 | 33 | @Override 34 | public String getUrlName() { 35 | return "github-branch-polling"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/dsl/GitHubBranchJobDslExtenstion.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.dsl; 2 | 3 | import antlr.ANTLRException; 4 | import com.github.kostyasha.github.integration.branch.GitHubBranchTrigger; 5 | import com.github.kostyasha.github.integration.branch.dsl.context.GitHubBranchTriggerDslContext; 6 | import hudson.Extension; 7 | import javaposse.jobdsl.dsl.helpers.triggers.TriggerContext; 8 | import javaposse.jobdsl.plugin.ContextExtensionPoint; 9 | import javaposse.jobdsl.plugin.DslExtensionMethod; 10 | 11 | 12 | /** 13 | * @author Kanstantsin Shautsou 14 | */ 15 | @Extension(optional = true) 16 | public class GitHubBranchJobDslExtenstion extends ContextExtensionPoint { 17 | @DslExtensionMethod(context = TriggerContext.class) 18 | public Object onBranch(Runnable closure) throws ANTLRException { 19 | 20 | GitHubBranchTriggerDslContext context = new GitHubBranchTriggerDslContext(); 21 | executeInContext(closure, context); 22 | 23 | GitHubBranchTrigger trigger = new GitHubBranchTrigger(context.cron(), context.mode(), context.events()); 24 | trigger.setPreStatus(context.isSetPreStatus()); 25 | trigger.setCancelQueued(context.isCancelQueued()); 26 | trigger.setAbortRunning(context.isAbortRunning()); 27 | trigger.setRepoProviders(context.repoProviders()); 28 | 29 | return trigger; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/dsl/context/events/GitHubBranchCommitChecksDslContext.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.dsl.context.events; 2 | 3 | 4 | import com.github.kostyasha.github.integration.branch.events.impl.GitHubBranchCommitEvent; 5 | import com.github.kostyasha.github.integration.branch.events.impl.commitchecks.GitHubBranchCommitCheck; 6 | import javaposse.jobdsl.dsl.Context; 7 | import javaposse.jobdsl.plugin.ContextExtensionPoint; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | public class GitHubBranchCommitChecksDslContext implements Context { 13 | 14 | private GitHubBranchCommitEvent event = new GitHubBranchCommitEvent(); 15 | private List checks = new ArrayList<>(); 16 | 17 | public void commitMessagePattern(Runnable closure) { 18 | GitHubBranchCommitMessageCheckDslContext commitContext = new GitHubBranchCommitMessageCheckDslContext(); 19 | ContextExtensionPoint.executeInContext(closure, commitContext); 20 | 21 | checks.add(commitContext.getCheck()); 22 | } 23 | 24 | public GitHubBranchCommitEvent getEvent() { 25 | event.setChecks(checks); 26 | return event; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/dsl/context/events/GitHubBranchCommitMessageCheckDslContext.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.dsl.context.events; 2 | 3 | import com.github.kostyasha.github.integration.branch.events.impl.commitchecks.impl.GitHubBranchCommitMessageCheck; 4 | import javaposse.jobdsl.dsl.Context; 5 | 6 | import java.util.LinkedHashSet; 7 | import java.util.Set; 8 | 9 | public class GitHubBranchCommitMessageCheckDslContext implements Context { 10 | private static final String LINE_SEPARATOR = System.lineSeparator(); 11 | 12 | private final Set matchCriteria = new LinkedHashSet<>(); 13 | private GitHubBranchCommitMessageCheck event = new GitHubBranchCommitMessageCheck(); 14 | 15 | public void excludeMatching() { 16 | event.setExclude(true); 17 | } 18 | 19 | public void matchCritieria(String matchCritieria) { 20 | this.matchCriteria.add(matchCritieria); 21 | } 22 | 23 | public GitHubBranchCommitMessageCheck getCheck() { 24 | event.setMatchCriteria(String.join(LINE_SEPARATOR, matchCriteria)); 25 | return event; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/dsl/context/events/GitHubBranchFilterEventDslContext.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.dsl.context.events; 2 | 3 | import com.github.kostyasha.github.integration.branch.events.impl.GitHubBranchRestrictionFilter; 4 | import javaposse.jobdsl.dsl.Context; 5 | 6 | import java.util.LinkedHashSet; 7 | import java.util.Set; 8 | 9 | public class GitHubBranchFilterEventDslContext implements Context { 10 | 11 | private static final String LINE_SEPARATOR = System.lineSeparator(); 12 | 13 | private final GitHubBranchRestrictionFilter filter = new GitHubBranchRestrictionFilter(); 14 | private final Set matchCriteria = new LinkedHashSet<>(); 15 | 16 | public void excludeMatching() { 17 | filter.setExclude(true); 18 | } 19 | 20 | public void matchAgainstPatterns() { 21 | filter.setMatchAsPattern(true); 22 | } 23 | 24 | public void matchCritieria(String matchCritieria) { 25 | this.matchCriteria.add(matchCritieria); 26 | } 27 | 28 | public GitHubBranchRestrictionFilter getFilter() { 29 | filter.setMatchCriteriaStr(String.join(LINE_SEPARATOR, matchCriteria)); 30 | return filter; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/events/GitHubBranchEventDescriptor.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.events; 2 | 3 | import hudson.DescriptorExtensionList; 4 | import hudson.model.Descriptor; 5 | import jenkins.model.Jenkins; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public abstract class GitHubBranchEventDescriptor extends Descriptor { 11 | public static DescriptorExtensionList all() { 12 | return Jenkins.getInstance().getDescriptorList(GitHubBranchEvent.class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/GitHubBranchCommitCheckDescriptor.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.events.impl.commitchecks; 2 | 3 | import hudson.DescriptorExtensionList; 4 | import hudson.model.Descriptor; 5 | import jenkins.model.Jenkins; 6 | 7 | /** 8 | * @see GitHubBranchCommitCheck 9 | */ 10 | public abstract class GitHubBranchCommitCheckDescriptor extends Descriptor { 11 | public static DescriptorExtensionList all() { 12 | return Jenkins.getInstance().getDescriptorList(GitHubBranchCommitCheck.class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/trigger/check/LocalRepoUpdater.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.trigger.check; 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranch; 4 | import com.github.kostyasha.github.integration.branch.GitHubBranchRepository; 5 | import org.kohsuke.github.GHBranch; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.function.Function; 10 | 11 | /** 12 | * @author Kanstantsin Shautsou 13 | */ 14 | public class LocalRepoUpdater implements Function { 15 | private static final Logger LOGGER = LoggerFactory.getLogger(LocalRepoUpdater.class); 16 | private final GitHubBranchRepository localRepo; 17 | 18 | private LocalRepoUpdater(GitHubBranchRepository localRepo) { 19 | this.localRepo = localRepo; 20 | } 21 | 22 | public static LocalRepoUpdater updateLocalRepo(GitHubBranchRepository localRepo) { 23 | return new LocalRepoUpdater(localRepo); 24 | } 25 | 26 | @Override 27 | public GHBranch apply(GHBranch remoteBranch) { 28 | LOGGER.trace("Updating local branch repository with [{}]", remoteBranch.getName()); 29 | localRepo.getBranches().put(remoteBranch.getName(), new GitHubBranch(remoteBranch)); 30 | 31 | return remoteBranch; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/trigger/check/SkipFirstRunForBranchFilter.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.trigger.check; 2 | 3 | 4 | import org.jenkinsci.plugins.github.pullrequest.utils.LoggingTaskListenerWrapper; 5 | import org.kohsuke.github.GHBranch; 6 | 7 | import java.util.function.Predicate; 8 | 9 | /** 10 | * @author Kanstantsin Shautsou 11 | */ 12 | public class SkipFirstRunForBranchFilter implements Predicate { 13 | private final LoggingTaskListenerWrapper logger; 14 | private final boolean skipFirstRun; 15 | 16 | private SkipFirstRunForBranchFilter(LoggingTaskListenerWrapper logger, boolean skipFirstRun) { 17 | this.logger = logger; 18 | this.skipFirstRun = skipFirstRun; 19 | } 20 | 21 | public static Predicate ifSkippedFirstRun(LoggingTaskListenerWrapper logger, boolean skipFirstRun) { 22 | return new SkipFirstRunForBranchFilter(logger, skipFirstRun); 23 | } 24 | 25 | @Override 26 | public boolean test(GHBranch remoteBranch) { 27 | if (skipFirstRun) { 28 | logger.info("Skipping first run for branch '{}'", remoteBranch.getName()); 29 | return false; 30 | } 31 | 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/utils/ItemHelpers.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.utils; 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranchRepository; 4 | import hudson.model.Item; 5 | import hudson.model.Job; 6 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository; 7 | 8 | import edu.umd.cs.findbugs.annotations.CheckForNull; 9 | import java.util.function.Predicate; 10 | 11 | import static java.util.Objects.nonNull; 12 | 13 | public class ItemHelpers { 14 | private ItemHelpers() { 15 | } 16 | 17 | 18 | public static Predicate isBuildable() { 19 | return item -> nonNull(item) && item instanceof Job && ((Job) item).isBuildable(); 20 | } 21 | 22 | 23 | @CheckForNull 24 | public static GitHubBranchRepository getBranchRepositoryFor(Item item) { 25 | if (item instanceof Job) { 26 | Job job = (Job) item; 27 | return job.getAction(GitHubBranchRepository.class); 28 | } 29 | 30 | return null; 31 | } 32 | 33 | @CheckForNull 34 | public static GitHubPRRepository getPRRepositoryFor(Item item) { 35 | if (item instanceof Job) { 36 | Job job = (Job) item; 37 | return job.getAction(GitHubPRRepository.class); 38 | } 39 | 40 | return null; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/utils/JobHelper.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.utils; 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranchCause; 4 | import com.github.kostyasha.github.integration.branch.GitHubBranchTrigger; 5 | import hudson.model.Job; 6 | import hudson.model.Run; 7 | 8 | import edu.umd.cs.findbugs.annotations.CheckForNull; 9 | 10 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghCauseFromRun; 11 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.triggerFrom; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | public class JobHelper { 17 | private JobHelper() { 18 | } 19 | 20 | @CheckForNull 21 | public static GitHubBranchTrigger ghBranchTiggerFromRun(Run run) { 22 | return triggerFrom(run.getParent(), GitHubBranchTrigger.class); 23 | } 24 | 25 | @CheckForNull 26 | public static GitHubBranchTrigger ghBranchTriggerFromJob(Job job) { 27 | return triggerFrom(job, GitHubBranchTrigger.class); 28 | } 29 | 30 | @CheckForNull 31 | public static GitHubBranchCause ghBranchCauseFromRun(Run run) { 32 | return ghCauseFromRun(run, GitHubBranchCause.class); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/webhook/BranchInfo.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.webhook; 2 | 3 | /** 4 | * Main info from webhook event. 5 | * 6 | * @author Kanstantsin Shautsou 7 | * @see GHBranchSubscriber 8 | */ 9 | public class BranchInfo { 10 | private String repo; 11 | private String branchName; 12 | private String fullRef; 13 | private boolean tag; 14 | 15 | public BranchInfo(String repo, String branchName, String fullRef, boolean tag) { 16 | this.repo = repo; 17 | this.branchName = branchName; 18 | this.fullRef = fullRef; 19 | this.tag = tag; 20 | } 21 | 22 | public boolean isTag() { 23 | return tag; 24 | } 25 | 26 | public String getRepo() { 27 | return repo; 28 | } 29 | 30 | public BranchInfo withRepo(String repo) { 31 | this.repo = repo; 32 | return this; 33 | } 34 | 35 | public String getBranchName() { 36 | return branchName; 37 | } 38 | 39 | public BranchInfo withBranchName(String branchName) { 40 | this.branchName = branchName; 41 | return this; 42 | } 43 | 44 | public String getFullRef() { 45 | return fullRef; 46 | } 47 | 48 | public BranchInfo withFullRef(String fullRef) { 49 | this.fullRef = fullRef; 50 | return this; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/branch/webhook/GitHubBranchRepositoryNameContributor.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.webhook; 2 | 3 | import com.cloudbees.jenkins.GitHubRepositoryName; 4 | import com.cloudbees.jenkins.GitHubRepositoryNameContributor; 5 | import com.github.kostyasha.github.integration.branch.GitHubBranchTrigger; 6 | import hudson.Extension; 7 | import hudson.model.Item; 8 | import hudson.model.Job; 9 | 10 | import java.util.Collection; 11 | 12 | import static com.github.kostyasha.github.integration.branch.utils.JobHelper.ghBranchTriggerFromJob; 13 | import static java.util.Objects.nonNull; 14 | 15 | /** 16 | * Branch Trigger tied to GitHub repo. Report it for GitHub doReRegister(). 17 | * 18 | * @author Kanstantsin Shautsou 19 | */ 20 | @Extension 21 | public class GitHubBranchRepositoryNameContributor extends GitHubRepositoryNameContributor { 22 | @Override 23 | public void parseAssociatedNames(Item item, Collection result) { 24 | if (!(item instanceof Job)) { 25 | return; 26 | } 27 | 28 | Job job = (Job) item; 29 | final GitHubBranchTrigger gitHubBranchTrigger = ghBranchTriggerFromJob(job); 30 | if (nonNull(gitHubBranchTrigger)) { 31 | result.add(gitHubBranchTrigger.getRepoFullName(job)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/GitHubBadgeAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic; 2 | 3 | import hudson.matrix.MatrixChildAction; 4 | import hudson.model.BuildBadgeAction; 5 | 6 | /** 7 | * @author Kanstantsin Shautsou 8 | */ 9 | public abstract class GitHubBadgeAction> implements BuildBadgeAction, MatrixChildAction { 10 | private String htmlUrl; 11 | private String title; 12 | 13 | public GitHubBadgeAction(GitHubCause cause) { 14 | this.htmlUrl = cause.getHtmlUrl().toString(); 15 | this.title = cause.getTitle(); 16 | } 17 | 18 | public String getHtmlUrl() { 19 | return htmlUrl; 20 | } 21 | 22 | /** 23 | * @see #htmlUrl 24 | */ 25 | public GitHubBadgeAction withHtmlUrl(String htmlUrl) { 26 | this.htmlUrl = htmlUrl; 27 | return this; 28 | } 29 | 30 | public String getTitle() { 31 | return title; 32 | } 33 | 34 | /** 35 | * @see #title 36 | */ 37 | public GitHubBadgeAction withTitle(String title) { 38 | this.title = title; 39 | return this; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/GitHubEnv.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic; 2 | 3 | import hudson.model.BooleanParameterValue; 4 | import hudson.model.ParameterValue; 5 | import hudson.model.StringParameterValue; 6 | 7 | import java.util.List; 8 | 9 | import static org.apache.commons.lang.StringEscapeUtils.escapeJava; 10 | import static org.apache.commons.lang.StringUtils.trimToEmpty; 11 | 12 | public interface GitHubEnv> { 13 | 14 | void addParam(T cause, List params); 15 | 16 | default ParameterValue param(String value) { 17 | return new StringParameterValue(toString(), escapeJava(trimToEmpty(value))); 18 | } 19 | 20 | default ParameterValue param(boolean value) { 21 | return new BooleanParameterValue(toString(), value); 22 | } 23 | 24 | static , X extends Enum & GitHubEnv> void getParams(Class enumClass, 25 | T cause, 26 | List params) { 27 | for (GitHubEnv env : enumClass.getEnumConstants()) { 28 | env.addParam(cause, params); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/GitHubRepoEnv.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic; 2 | 3 | import hudson.model.ParameterValue; 4 | 5 | import java.util.List; 6 | import java.util.function.Function; 7 | 8 | /** 9 | * @author Kanstantsin Shautsou 10 | */ 11 | public enum GitHubRepoEnv implements GitHubEnv> { 12 | GIT_URL(GitHubCause::getGitUrl), 13 | SSH_URL(GitHubCause::getSshUrl); 14 | 15 | public static final String PREFIX = "GITHUB_REPO_"; 16 | 17 | private Function, ParameterValue> fun; 18 | 19 | GitHubRepoEnv(Function, String> fun) { 20 | this.fun = c -> param(fun.apply(c)); 21 | } 22 | 23 | @Override 24 | public void addParam(GitHubCause cause, List params) { 25 | params.add(fun.apply(cause)); 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return PREFIX.concat(name()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/GitHubRepositoryFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic; 2 | 3 | import hudson.model.Job; 4 | import jenkins.model.TransientActionFactory; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * @author Kanstantsin Shautsou 10 | */ 11 | public abstract class GitHubRepositoryFactory, T extends GitHubTrigger> 12 | extends TransientActionFactory { 13 | private static final Logger LOG = LoggerFactory.getLogger(GitHubRepositoryFactory.class); 14 | 15 | @Override 16 | public Class type() { 17 | return Job.class; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/dsl/repoproviders/GHRepoPermissionDslContext.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.dsl.repoproviders; 2 | 3 | import com.github.kostyasha.github.integration.generic.repoprovider.GHPermission; 4 | import javaposse.jobdsl.dsl.Context; 5 | 6 | /** 7 | * @author Kanstantsin Shautsou 8 | */ 9 | public class GHRepoPermissionDslContext implements Context { 10 | private GHPermission permission = GHPermission.ADMIN; 11 | 12 | public void admin() { 13 | permission = GHPermission.ADMIN; 14 | } 15 | 16 | public void pull() { 17 | permission = GHPermission.PULL; 18 | } 19 | 20 | public void push() { 21 | permission = GHPermission.PUSH; 22 | } 23 | 24 | public GHPermission permission() { 25 | return permission; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/dsl/repoproviders/GitHubPluginRepoProviderDslContext.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.dsl.repoproviders; 2 | 3 | import com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider; 4 | import javaposse.jobdsl.dsl.Context; 5 | import javaposse.jobdsl.plugin.ContextExtensionPoint; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public class GitHubPluginRepoProviderDslContext implements Context { 11 | 12 | private GitHubPluginRepoProvider provider = new GitHubPluginRepoProvider(); 13 | 14 | public void cacheConnection(boolean cacheConnection) { 15 | provider.setCacheConnection(cacheConnection); 16 | } 17 | 18 | public void manageHooks(boolean manageHooks) { 19 | provider.setManageHooks(manageHooks); 20 | } 21 | 22 | public void permission(Runnable closure) { 23 | GHRepoPermissionDslContext permissionContext = new GHRepoPermissionDslContext(); 24 | ContextExtensionPoint.executeInContext(closure, permissionContext); 25 | 26 | provider.setRepoPermission(permissionContext.permission()); 27 | } 28 | 29 | public GitHubPluginRepoProvider getProvider() { 30 | return provider; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/dsl/repoproviders/GitHubRepoProvidersDslContext.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.dsl.repoproviders; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubRepoProvider; 4 | import javaposse.jobdsl.dsl.Context; 5 | import javaposse.jobdsl.plugin.ContextExtensionPoint; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * @author Kanstantsin Shautsou 12 | */ 13 | public class GitHubRepoProvidersDslContext implements Context { 14 | 15 | private List repoProviders = new ArrayList<>(); 16 | 17 | public void gitHubPlugin(Runnable closure) { 18 | GitHubPluginRepoProviderDslContext githubPluginContext = new GitHubPluginRepoProviderDslContext(); 19 | ContextExtensionPoint.executeInContext(closure, githubPluginContext); 20 | 21 | repoProviders.add(githubPluginContext.getProvider()); 22 | } 23 | 24 | public List repoProviders() { 25 | return repoProviders; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/errors/GitHubError.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.errors; 2 | 3 | import hudson.ExtensionPoint; 4 | 5 | import edu.umd.cs.findbugs.annotations.NonNull; 6 | 7 | /** 8 | * Custom errors that participate in list of {@link GitHubErrorsAction}. 9 | * index.groovy 10 | * 11 | * @author Kanstantsin Shautsou 12 | */ 13 | public abstract class GitHubError implements ExtensionPoint { 14 | private String description; 15 | 16 | public GitHubError(@NonNull String description) { 17 | this.description = description; 18 | } 19 | 20 | @NonNull 21 | public abstract String getTitle(); 22 | 23 | /** 24 | * Whether to show error on job page. Useful when error visibility will be known after delay. 25 | */ 26 | public boolean isVisible() { 27 | return true; 28 | } 29 | 30 | /** 31 | * Raw displayed html content as description. 32 | */ 33 | @NonNull 34 | public String getHtmlDescription() { 35 | return description; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/errors/impl/GitHubHookRegistrationError.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.errors.impl; 2 | 3 | import com.github.kostyasha.github.integration.generic.errors.GitHubError; 4 | 5 | import edu.umd.cs.findbugs.annotations.NonNull; 6 | 7 | /** 8 | * When hook registration in trigger fails. 9 | * 10 | * @author Kanstantsin Shautsou 11 | */ 12 | public class GitHubHookRegistrationError extends GitHubError { 13 | public GitHubHookRegistrationError(@NonNull String description) { 14 | super(description); 15 | } 16 | 17 | @NonNull 18 | @Override 19 | public String getTitle() { 20 | return "GitHub Hook Registration error"; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/errors/impl/GitHubRepoProviderError.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.errors.impl; 2 | 3 | import com.github.kostyasha.github.integration.generic.errors.GitHubError; 4 | 5 | import edu.umd.cs.findbugs.annotations.NonNull; 6 | 7 | /** 8 | * Used during {@link com.github.kostyasha.github.integration.generic.GitHubRepoProvider} resolve. 9 | * 10 | * @author Kanstantsin Shautsou 11 | */ 12 | public class GitHubRepoProviderError extends GitHubError { 13 | 14 | public GitHubRepoProviderError(@NonNull String description) { 15 | super(description); 16 | } 17 | 18 | @NonNull 19 | @Override 20 | public String getTitle() { 21 | return "GitHub Repo Provider Error"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/generic/repoprovider/GHPermission.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.repoprovider; 2 | 3 | /** 4 | * @author Kanstantsin Shautsou 5 | */ 6 | public enum GHPermission { 7 | ADMIN, PUSH, PULL 8 | } 9 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/GitHubParametersAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | 6 | import hudson.EnvVars; 7 | import hudson.Extension; 8 | import hudson.model.Action; 9 | import hudson.model.EnvironmentContributor; 10 | import hudson.model.InvisibleAction; 11 | import hudson.model.ParameterValue; 12 | import hudson.model.ParametersAction; 13 | import hudson.model.Run; 14 | import hudson.model.TaskListener; 15 | import hudson.model.Queue.Item; 16 | import hudson.model.Queue.Task; 17 | import hudson.model.queue.FoldableAction; 18 | 19 | /** 20 | * Simpler replacement for {@link ParametersAction} that does not stand in the way of 'folding' queue items 21 | * @author atanasenko 22 | * 23 | */ 24 | public class GitHubParametersAction extends InvisibleAction implements FoldableAction { 25 | 26 | private List params; 27 | 28 | public GitHubParametersAction(List params) { 29 | this.params = params; 30 | } 31 | 32 | @Override 33 | public void foldIntoExisting(Item item, Task owner, List actions) { 34 | item.addOrReplaceAction(this); 35 | } 36 | 37 | @Extension 38 | public static class GitHubEnvContributor extends EnvironmentContributor { 39 | @Override 40 | public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) throws IOException, InterruptedException { 41 | GitHubParametersAction action = r.getAction(GitHubParametersAction.class); 42 | if (action == null) { 43 | return; 44 | } 45 | action.params.forEach(p -> p.buildEnvironment(r, envs)); 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/action/GitHubBranchAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.action; 2 | 3 | import org.kohsuke.github.GHRepository; 4 | 5 | /** 6 | * Add a link to repository branch 7 | * 8 | * @author Anton Tanasenko 9 | */ 10 | public class GitHubBranchAction extends GitHubLinkAction { 11 | 12 | private String branch; 13 | 14 | public GitHubBranchAction(GHRepository remoteRepository, String branch) { 15 | super(buildUrl(remoteRepository, branch)); 16 | this.branch = branch; 17 | } 18 | 19 | @Override 20 | public String getDisplayName() { 21 | return "Branch " + branch; 22 | } 23 | 24 | private static String buildUrl(GHRepository remoteRepository, String branch) { 25 | String repoUrl = remoteRepository.getHtmlUrl().toExternalForm(); 26 | if (remoteRepository.getDefaultBranch().equals(branch)) { 27 | return repoUrl; 28 | } 29 | return repoUrl + "/tree/" + branch; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/action/GitHubLinkAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.action; 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranch; 4 | import hudson.model.Action; 5 | 6 | /** 7 | * Add a simple link to item 8 | * 9 | * @author Anton Tanasenko 10 | */ 11 | public abstract class GitHubLinkAction implements Action { 12 | 13 | private final String url; 14 | 15 | protected GitHubLinkAction(String url) { 16 | this.url = url; 17 | } 18 | 19 | @Override 20 | public String getIconFileName() { 21 | return GitHubBranch.getIconFileName(); 22 | } 23 | 24 | @Override 25 | public String getUrlName() { 26 | return url; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/action/GitHubPRAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.action; 2 | 3 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRPullRequest; 4 | import org.kohsuke.github.GHRepository; 5 | 6 | /** 7 | * Add a link to repository pr 8 | * 9 | * @author Anton Tanasenko 10 | */ 11 | public class GitHubPRAction extends GitHubLinkAction { 12 | 13 | private Integer pr; 14 | 15 | public GitHubPRAction(GHRepository remoteRepository, Integer pr) { 16 | super(buildUrl(remoteRepository, pr)); 17 | this.pr = pr; 18 | } 19 | 20 | @Override 21 | public String getIconFileName() { 22 | return GitHubPRPullRequest.getIconFileName(); 23 | } 24 | 25 | @Override 26 | public String getDisplayName() { 27 | return "PR#" + pr; 28 | } 29 | 30 | private static String buildUrl(GHRepository remoteRepository, Integer pr) { 31 | return remoteRepository.getHtmlUrl().toExternalForm() + "/pull/" + pr; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/action/GitHubRepoAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.action; 2 | 3 | import org.kohsuke.github.GHRepository; 4 | 5 | /** 6 | * Add a link to repository 7 | * 8 | * @author Anton Tanasenko 9 | */ 10 | public class GitHubRepoAction extends GitHubLinkAction { 11 | 12 | private final String name; 13 | 14 | public GitHubRepoAction(GHRepository remoteRepository) { 15 | super(remoteRepository.getHtmlUrl().toExternalForm()); 16 | this.name = remoteRepository.getFullName(); 17 | } 18 | 19 | @Override 20 | public String getDisplayName() { 21 | return "Repo " + name; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/action/GitHubTagAction.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.action; 2 | 3 | import com.github.kostyasha.github.integration.tag.GitHubTag; 4 | import org.kohsuke.github.GHRepository; 5 | 6 | /** 7 | * Add a link to repository branch 8 | * 9 | * @author Anton Tanasenko 10 | */ 11 | public class GitHubTagAction extends GitHubLinkAction { 12 | 13 | private String tag; 14 | 15 | public GitHubTagAction(GHRepository remoteRepository, String tag) { 16 | super(buildUrl(remoteRepository, tag)); 17 | this.tag = tag; 18 | } 19 | 20 | @Override 21 | public String getDisplayName() { 22 | return "Tag " + tag; 23 | } 24 | 25 | @Override 26 | public String getIconFileName() { 27 | return GitHubTag.getIconFileName(); 28 | } 29 | 30 | private static String buildUrl(GHRepository remoteRepository, String tag) { 31 | String repoUrl = remoteRepository.getHtmlUrl().toExternalForm(); 32 | if (remoteRepository.getDefaultBranch().equals(tag)) { 33 | return repoUrl; 34 | } 35 | return repoUrl + "/releases/tag/" + tag; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/category/GitHubBranchSCMHeadCategory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.category; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.head.GitHubBranchSCMHead; 4 | import jenkins.scm.api.SCMHead; 5 | import jenkins.util.NonLocalizable; 6 | import org.jvnet.localizer.Localizable; 7 | 8 | import edu.umd.cs.findbugs.annotations.NonNull; 9 | 10 | public class GitHubBranchSCMHeadCategory extends GitHubSCMHeadCategory { 11 | public static final GitHubBranchSCMHeadCategory BRANCH = new GitHubBranchSCMHeadCategory(new NonLocalizable("Branches")); 12 | 13 | public GitHubBranchSCMHeadCategory(@NonNull String urlName, Localizable pronoun) { 14 | super(urlName, pronoun); 15 | } 16 | 17 | public GitHubBranchSCMHeadCategory(Localizable pronoun) { 18 | super(pronoun); 19 | } 20 | 21 | @Override 22 | public boolean isMatch(@NonNull SCMHead instance) { 23 | return instance instanceof GitHubBranchSCMHead; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/category/GitHubPRSCMHeadCategory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.category; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.head.GitHubPRSCMHead; 4 | import jenkins.scm.api.SCMHead; 5 | import jenkins.util.NonLocalizable; 6 | import org.jvnet.localizer.Localizable; 7 | 8 | import edu.umd.cs.findbugs.annotations.NonNull; 9 | 10 | public class GitHubPRSCMHeadCategory extends GitHubSCMHeadCategory { 11 | public static final GitHubPRSCMHeadCategory PR = new GitHubPRSCMHeadCategory("pr", new NonLocalizable("Pull Requests")); 12 | 13 | public GitHubPRSCMHeadCategory(@NonNull String urlName, Localizable pronoun) { 14 | super(urlName, pronoun); 15 | } 16 | 17 | @Override 18 | public boolean isMatch(@NonNull SCMHead instance) { 19 | return instance instanceof GitHubPRSCMHead; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/category/GitHubSCMHeadCategory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.category; 2 | 3 | import jenkins.scm.api.SCMHeadCategory; 4 | import org.jvnet.localizer.Localizable; 5 | 6 | import edu.umd.cs.findbugs.annotations.NonNull; 7 | 8 | public abstract class GitHubSCMHeadCategory extends SCMHeadCategory { 9 | 10 | public GitHubSCMHeadCategory(@NonNull String urlName, Localizable pronoun) { 11 | super(urlName, pronoun); 12 | } 13 | 14 | 15 | public GitHubSCMHeadCategory(Localizable pronoun) { 16 | super(pronoun); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/category/GitHubTagSCMHeadCategory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.category; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.head.GitHubTagSCMHead; 4 | import jenkins.scm.api.SCMHead; 5 | import jenkins.util.NonLocalizable; 6 | import org.jvnet.localizer.Localizable; 7 | 8 | import edu.umd.cs.findbugs.annotations.NonNull; 9 | 10 | public class GitHubTagSCMHeadCategory extends GitHubSCMHeadCategory { 11 | public static final GitHubTagSCMHeadCategory TAG = new GitHubTagSCMHeadCategory("tag", new NonLocalizable("Tags")); 12 | 13 | public GitHubTagSCMHeadCategory(@NonNull String name, Localizable displayName) { 14 | super(name, displayName); 15 | } 16 | 17 | @NonNull 18 | @Override 19 | protected Localizable defaultDisplayName() { 20 | return new NonLocalizable("Tag"); 21 | } 22 | 23 | @Override 24 | public boolean isMatch(@NonNull SCMHead instance) { 25 | return instance instanceof GitHubTagSCMHead; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/handler/GitHubHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.handler; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubCause; 4 | import hudson.model.AbstractDescribableImpl; 5 | import hudson.model.TaskListener; 6 | import org.kohsuke.github.GitHub; 7 | 8 | import edu.umd.cs.findbugs.annotations.NonNull; 9 | import java.io.IOException; 10 | import java.util.stream.Stream; 11 | 12 | import static org.jenkinsci.plugins.github.pullrequest.utils.IOUtils.forEachIo; 13 | 14 | /** 15 | * @author Kanstantsin Shautsou 16 | */ 17 | public abstract class GitHubHandler extends AbstractDescribableImpl { 18 | 19 | public abstract void handle(@NonNull GitHubSourceContext context) throws IOException; 20 | 21 | protected void processCauses(GitHubSourceContext context, Stream> causeStream) throws IOException { 22 | GitHub github = context.getGitHub(); 23 | TaskListener listener = context.getListener(); 24 | 25 | listener.getLogger().println("GitHub rate limit before check: " + github.getRateLimit()); 26 | 27 | // run the process 28 | forEachIo(causeStream, context::observe); 29 | 30 | listener.getLogger().println("GitHub rate limit after check: " + github.getRateLimit()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/handler/GitHubHandlerDescriptor.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.handler; 2 | 3 | import hudson.DescriptorExtensionList; 4 | import hudson.ExtensionPoint; 5 | import hudson.model.Descriptor; 6 | import jenkins.model.Jenkins; 7 | 8 | /** 9 | * @author Kanstantsin Shautsou 10 | */ 11 | public abstract class GitHubHandlerDescriptor extends Descriptor implements ExtensionPoint { 12 | public static DescriptorExtensionList getAllGitHubHandlerDescriptors() { 13 | return Jenkins.getInstance().getDescriptorList(GitHubHandler.class); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/head/GitHubBranchSCMHead.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.head; 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranchCause; 4 | import org.kohsuke.github.GHBranch; 5 | import org.kohsuke.github.GHRepository; 6 | 7 | import edu.umd.cs.findbugs.annotations.NonNull; 8 | import java.io.IOException; 9 | 10 | public class GitHubBranchSCMHead extends GitHubSCMHead { 11 | private static final long serialVersionUID = 1L; 12 | 13 | public GitHubBranchSCMHead(@NonNull String name, String sourceId) { 14 | super(name, sourceId); 15 | } 16 | 17 | @Override 18 | public String getPronoun() { 19 | return "Branch " + getName(); 20 | } 21 | 22 | @Override 23 | public String fetchHeadSha(GHRepository remoteRepo) throws IOException { 24 | GHBranch branch = remoteRepo.getBranch(getName()); 25 | if (branch == null) { 26 | throw new IOException("No branch " + getName() + " in " + remoteRepo.getFullName()); 27 | } 28 | return branch.getSHA1(); 29 | } 30 | 31 | @Override 32 | public String getHeadSha(GitHubBranchCause cause) { 33 | return cause.getCommitSha(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/head/GitHubSCMHead.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.head; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubCause; 4 | import com.github.kostyasha.github.integration.multibranch.revision.GitHubSCMRevision; 5 | import jenkins.scm.api.SCMHead; 6 | import org.kohsuke.github.GHRepository; 7 | 8 | import edu.umd.cs.findbugs.annotations.NonNull; 9 | import java.io.IOException; 10 | 11 | public abstract class GitHubSCMHead> extends SCMHead { 12 | private static final long serialVersionUID = 1L; 13 | 14 | private final String sourceId; 15 | 16 | public GitHubSCMHead(@NonNull String name, String sourceId) { 17 | super(name); 18 | this.sourceId = sourceId; 19 | } 20 | 21 | public String getSourceId() { 22 | return sourceId; 23 | } 24 | 25 | public abstract String fetchHeadSha(GHRepository remoteRepo) throws IOException; 26 | 27 | public abstract String getHeadSha(T cause); 28 | 29 | public GitHubSCMRevision createSCMRevision(T cause) { 30 | return new GitHubSCMRevision(this, getHeadSha(cause), cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/head/GitHubTagSCMHead.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.head; 2 | 3 | import com.github.kostyasha.github.integration.tag.GitHubTag; 4 | import com.github.kostyasha.github.integration.tag.GitHubTagCause; 5 | import org.kohsuke.github.GHRepository; 6 | import org.kohsuke.github.GHTag; 7 | 8 | import edu.umd.cs.findbugs.annotations.NonNull; 9 | import java.io.IOException; 10 | 11 | public class GitHubTagSCMHead extends GitHubSCMHead { 12 | private static final long serialVersionUID = 1L; 13 | 14 | public GitHubTagSCMHead(@NonNull String name, String sourceId) { 15 | super(name, sourceId); 16 | } 17 | 18 | @Override 19 | public String getPronoun() { 20 | return "Tag " + getName(); 21 | } 22 | 23 | @Override 24 | public String fetchHeadSha(GHRepository remoteRepo) throws IOException { 25 | GHTag tag = GitHubTag.findRemoteTag(remoteRepo, getName()); 26 | if (tag == null) { 27 | throw new IOException("No tag " + getName() + " in " + remoteRepo.getFullName()); 28 | } 29 | return tag.getCommit().getSHA1(); 30 | } 31 | 32 | public String getHeadSha(GitHubTagCause cause) { 33 | return cause.getCommitSha(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/hooks/GitHubBranchSCMHeadEvent.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.hooks; 2 | 3 | import com.github.kostyasha.github.integration.branch.webhook.BranchInfo; 4 | import com.github.kostyasha.github.integration.multibranch.head.GitHubBranchSCMHead; 5 | import jenkins.scm.api.SCMHead; 6 | import jenkins.scm.api.SCMRevision; 7 | import jenkins.scm.api.SCMSource; 8 | 9 | import edu.umd.cs.findbugs.annotations.CheckForNull; 10 | import edu.umd.cs.findbugs.annotations.NonNull; 11 | import java.util.Collections; 12 | import java.util.Map; 13 | 14 | /** 15 | * @author Kanstantsin Shautsou 16 | */ 17 | public class GitHubBranchSCMHeadEvent extends GitHubScmHeadEvent { 18 | public GitHubBranchSCMHeadEvent(@NonNull Type type, long timestamp, @NonNull BranchInfo payload, @CheckForNull String origin) { 19 | super(type, timestamp, payload, origin); 20 | } 21 | 22 | @NonNull 23 | @Override 24 | protected String getSourceRepo() { 25 | return getPayload().getRepo(); 26 | } 27 | 28 | @NonNull 29 | @Override 30 | public Map heads(@NonNull SCMSource source) { 31 | if (!isMatch(source)) { 32 | return Collections.emptyMap(); 33 | } 34 | return Collections.singletonMap(new GitHubBranchSCMHead(getPayload().getBranchName(), source.getId()), null); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/hooks/GitHubPullRequestScmHeadEvent.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.hooks; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.head.GitHubPRSCMHead; 4 | import hudson.scm.SCM; 5 | import jenkins.scm.api.SCMHead; 6 | import jenkins.scm.api.SCMRevision; 7 | import jenkins.scm.api.SCMSource; 8 | import org.jenkinsci.plugins.github.pullrequest.webhook.PullRequestInfo; 9 | 10 | import edu.umd.cs.findbugs.annotations.CheckForNull; 11 | import edu.umd.cs.findbugs.annotations.NonNull; 12 | import java.util.Collections; 13 | import java.util.Map; 14 | 15 | /** 16 | * @author Kanstantsin Shautsou 17 | */ 18 | public class GitHubPullRequestScmHeadEvent extends GitHubScmHeadEvent { 19 | public GitHubPullRequestScmHeadEvent(@NonNull Type type, long timestamp, @NonNull PullRequestInfo payload, 20 | @CheckForNull String origin) { 21 | super(type, timestamp, payload, origin); 22 | } 23 | 24 | @NonNull 25 | @Override 26 | protected String getSourceRepo() { 27 | return getPayload().getRepo(); 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public Map heads(@NonNull SCMSource source) { 33 | if (!isMatch(source)) { 34 | return Collections.emptyMap(); 35 | } 36 | 37 | return Collections.singletonMap( 38 | new GitHubPRSCMHead(getPayload().getNum(), getPayload().getTarget(), source.getId()), null 39 | ); 40 | } 41 | 42 | @Override 43 | public boolean isMatch(@NonNull SCM scm) { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/hooks/GitHubScmSourceRepositoryNameContributor.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.hooks; 2 | 3 | import com.cloudbees.jenkins.GitHubRepositoryName; 4 | import com.cloudbees.jenkins.GitHubRepositoryNameContributor; 5 | import com.github.kostyasha.github.integration.multibranch.GitHubSCMSource; 6 | import hudson.Extension; 7 | import hudson.model.Item; 8 | import jenkins.scm.api.SCMSource; 9 | import jenkins.scm.api.SCMSourceOwner; 10 | 11 | import java.util.Collection; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | @Extension 17 | public class GitHubScmSourceRepositoryNameContributor extends GitHubRepositoryNameContributor { 18 | @Override 19 | public void parseAssociatedNames(Item item, Collection result) { 20 | if (item instanceof SCMSourceOwner) { 21 | SCMSourceOwner sourceOwner = (SCMSourceOwner) item; 22 | for (SCMSource source : sourceOwner.getSCMSources()) { 23 | if (source instanceof GitHubSCMSource) { 24 | GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) source; 25 | result.add(gitHubSCMSource.getRepoFullName()); 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/hooks/GitHubTagSCMHeadEvent.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.hooks; 2 | 3 | import com.github.kostyasha.github.integration.branch.webhook.BranchInfo; 4 | import com.github.kostyasha.github.integration.multibranch.head.GitHubTagSCMHead; 5 | import jenkins.scm.api.SCMHead; 6 | import jenkins.scm.api.SCMRevision; 7 | import jenkins.scm.api.SCMSource; 8 | 9 | import edu.umd.cs.findbugs.annotations.CheckForNull; 10 | import edu.umd.cs.findbugs.annotations.NonNull; 11 | import java.util.Collections; 12 | import java.util.Map; 13 | 14 | /** 15 | * @author Kanstantsin Shautsou 16 | */ 17 | public class GitHubTagSCMHeadEvent extends GitHubScmHeadEvent { 18 | public GitHubTagSCMHeadEvent(@NonNull Type type, long timestamp, @NonNull BranchInfo payload, @CheckForNull String origin) { 19 | super(type, timestamp, payload, origin); 20 | } 21 | 22 | @NonNull 23 | @Override 24 | protected String getSourceRepo() { 25 | return getPayload().getRepo(); 26 | } 27 | 28 | @NonNull 29 | @Override 30 | public Map heads(@NonNull SCMSource source) { 31 | if (!isMatch(source)) { 32 | return Collections.emptyMap(); 33 | } 34 | return Collections.singletonMap(new GitHubTagSCMHead(getPayload().getBranchName(), source.getId()), null); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/repoprovider/GitHubRepoProvider2.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.repoprovider; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.GitHubSCMSource; 4 | import hudson.DescriptorExtensionList; 5 | import hudson.ExtensionPoint; 6 | import hudson.model.AbstractDescribableImpl; 7 | import hudson.model.Descriptor; 8 | import jenkins.model.Jenkins; 9 | import org.kohsuke.github.GHRepository; 10 | import org.kohsuke.github.GitHub; 11 | 12 | import edu.umd.cs.findbugs.annotations.NonNull; 13 | 14 | /** 15 | * @author Kanstantsin Shautsou 16 | */ 17 | public abstract class GitHubRepoProvider2 extends AbstractDescribableImpl implements ExtensionPoint { 18 | 19 | 20 | public abstract void registerHookFor(GitHubSCMSource source); 21 | 22 | public abstract boolean isManageHooks(GitHubSCMSource source); 23 | 24 | @NonNull 25 | public abstract GitHub getGitHub(GitHubSCMSource source); 26 | 27 | public abstract GHRepository getGHRepository(GitHubSCMSource source); 28 | 29 | public abstract static class GitHubRepoProviderDescriptor2 30 | extends Descriptor { 31 | @NonNull 32 | public abstract String getDisplayName(); 33 | 34 | public static DescriptorExtensionList allRepoProviders2() { 35 | return Jenkins.getInstance().getDescriptorList(GitHubRepoProvider2.class); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/repoprovider/GitHubRepoProviderDescriptor2.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.repoprovider; 2 | 3 | /** 4 | * @author Kanstantsin Shautsou 5 | */ 6 | public class GitHubRepoProviderDescriptor2 { 7 | } 8 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/revision/GitHubSCMRevision.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.revision; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubCause; 4 | import jenkins.plugins.git.AbstractGitSCMSource; 5 | import jenkins.scm.api.SCMHead; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public class GitHubSCMRevision extends AbstractGitSCMSource.SCMRevisionImpl { 11 | 12 | private transient GitHubCause cause; 13 | private transient Object remoteData; 14 | 15 | public GitHubSCMRevision(SCMHead head, String hash, GitHubCause cause) { 16 | super(head, hash); 17 | this.cause = cause; 18 | } 19 | 20 | public GitHubCause getCause() { 21 | return cause; 22 | } 23 | 24 | public GitHubSCMRevision setCause(GitHubCause cause) { 25 | this.cause = cause; 26 | return this; 27 | } 28 | 29 | public Object getRemoteData() { 30 | return remoteData; 31 | } 32 | 33 | /** 34 | * Provides a way for SCMSourceCriteria implementations to get a hold of the remote data (branch, tag, etc) 35 | */ 36 | public GitHubSCMRevision setRemoteData(Object remoteData) { 37 | this.remoteData = remoteData; 38 | return this; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/scm/AsIsGitSCMFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.scm; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.GitHubSCMSource; 4 | import hudson.Extension; 5 | import hudson.plugins.git.GitSCM; 6 | import jenkins.scm.api.SCMHead; 7 | import jenkins.scm.api.SCMRevision; 8 | import org.jenkinsci.Symbol; 9 | import org.kohsuke.stapler.DataBoundConstructor; 10 | 11 | import edu.umd.cs.findbugs.annotations.NonNull; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | public class AsIsGitSCMFactory extends GitHubSCMFactory { 17 | 18 | private GitSCM gitSCM; 19 | 20 | @DataBoundConstructor 21 | public AsIsGitSCMFactory(GitSCM gitSCM) { 22 | this.gitSCM = gitSCM; 23 | } 24 | 25 | public GitSCM getGitSCM() { 26 | return gitSCM; 27 | } 28 | 29 | @Override 30 | public GitSCM createScm(GitHubSCMSource scmSource, SCMHead scmHead, SCMRevision scmRevision) { 31 | return new GitSCM( 32 | gitSCM.getUserRemoteConfigs(), 33 | gitSCM.getBranches(), 34 | gitSCM.isDoGenerateSubmoduleConfigurations(), 35 | gitSCM.getSubmoduleCfg(), 36 | gitSCM.getBrowser(), 37 | gitSCM.getGitTool(), 38 | gitSCM.getExtensions() 39 | ); 40 | } 41 | 42 | @Symbol("asIsGITScm") 43 | @Extension 44 | public static class DescriptorImpl extends GitHubSCMFactoryDescriptor { 45 | @NonNull 46 | @Override 47 | public String getDisplayName() { 48 | return "As Is Git SCM"; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/scm/GitHubSCMFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.scm; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.GitHubSCMSource; 4 | import hudson.DescriptorExtensionList; 5 | import hudson.ExtensionPoint; 6 | import hudson.model.AbstractDescribableImpl; 7 | import hudson.model.Descriptor; 8 | import hudson.plugins.git.GitSCM; 9 | import jenkins.model.Jenkins; 10 | import jenkins.scm.api.SCMHead; 11 | import jenkins.scm.api.SCMRevision; 12 | 13 | public abstract class GitHubSCMFactory extends AbstractDescribableImpl 14 | implements ExtensionPoint { 15 | 16 | public abstract GitSCM createScm(GitHubSCMSource scmSource, SCMHead scmHead, SCMRevision scmRevision); 17 | 18 | public abstract static class GitHubSCMFactoryDescriptor extends Descriptor { 19 | public static DescriptorExtensionList getGitHubSCMFactoryDescriptors() { 20 | return Jenkins.getInstance().getDescriptorList(GitHubSCMFactory.class); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/scm/NoGitHubSCMFactory.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.scm; 2 | 3 | import com.github.kostyasha.github.integration.multibranch.GitHubSCMSource; 4 | import hudson.Extension; 5 | import hudson.plugins.git.GitSCM; 6 | import jenkins.scm.api.SCMHead; 7 | import jenkins.scm.api.SCMRevision; 8 | import org.jenkinsci.Symbol; 9 | import org.kohsuke.stapler.DataBoundConstructor; 10 | 11 | import edu.umd.cs.findbugs.annotations.NonNull; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | public class NoGitHubSCMFactory extends GitHubSCMFactory { 17 | 18 | @DataBoundConstructor 19 | public NoGitHubSCMFactory() { 20 | } 21 | 22 | @Override 23 | public GitSCM createScm(GitHubSCMSource scmSource, SCMHead scmHead, SCMRevision scmRevision) { 24 | return new NoGitSCM(null); 25 | } 26 | 27 | @Symbol("noGITScm") 28 | @Extension 29 | public static class DescriptorImpl extends GitHubSCMFactoryDescriptor { 30 | @NonNull 31 | @Override 32 | public String getDisplayName() { 33 | return "No SCM"; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/scm/NoGitSCM.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.scm; 2 | 3 | import hudson.FilePath; 4 | import hudson.Launcher; 5 | import hudson.model.AbstractBuild; 6 | import hudson.model.Run; 7 | import hudson.model.TaskListener; 8 | import hudson.plugins.git.GitSCM; 9 | import hudson.scm.ChangeLogParser; 10 | import hudson.scm.SCMRevisionState; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.Map; 15 | 16 | /** 17 | * @author Kanstantsin Shautsou 18 | */ 19 | public class NoGitSCM extends GitSCM { 20 | 21 | public NoGitSCM(String repositoryUrl) { 22 | super(repositoryUrl); 23 | } 24 | 25 | @Override 26 | public ChangeLogParser createChangeLogParser() { 27 | return null; 28 | } 29 | 30 | @Override 31 | public void buildEnvVars(AbstractBuild build, Map env) { 32 | } 33 | 34 | @Override 35 | public void buildEnvironment(Run build, Map env) { 36 | } 37 | 38 | @Override 39 | public void checkout(Run build, Launcher launcher, FilePath workspace, TaskListener listener, 40 | File changelogFile, SCMRevisionState baseline) throws IOException, InterruptedException { 41 | listener.getLogger().println("No SCM checkout."); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/tag/GitHubTag.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag; 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranch; 4 | import hudson.Functions; 5 | import org.kohsuke.github.GHRepository; 6 | import org.kohsuke.github.GHTag; 7 | 8 | import java.io.IOException; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import java.util.stream.Stream; 12 | import java.util.stream.StreamSupport; 13 | 14 | /** 15 | * Store local information about tag. 16 | * 17 | * @author Kanstantsin Shautsou 18 | * @see GitHubTagRepository 19 | */ 20 | public class GitHubTag extends GitHubBranch { 21 | 22 | public GitHubTag(GHTag ghTag) { 23 | this(ghTag.getName(), ghTag.getCommit().getSHA1(), ghTag.getOwner()); 24 | } 25 | 26 | public GitHubTag(String name, String commitSha, GHRepository ghRepository) { 27 | super(name, commitSha, ghRepository); 28 | } 29 | 30 | public static String getIconFileName() { 31 | return Functions.getResourcePath() + "/plugin/github-pullrequest/git-tag.svg"; 32 | } 33 | 34 | public static GHTag findRemoteTag(GHRepository repo, String name) throws IOException { 35 | Stream tagStream = StreamSupport.stream(repo.listTags().spliterator(), false); 36 | return tagStream.filter(t -> t.getName().equals(name)).findFirst().orElse(null); 37 | } 38 | 39 | public static List getAllTags(GHRepository repo) throws IOException { 40 | List tags = new ArrayList<>(); 41 | repo.listTags().forEach(tags::add); 42 | return tags; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/tag/GitHubTagEnv.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubEnv; 4 | import com.github.kostyasha.github.integration.generic.GitHubRepoEnv; 5 | import hudson.model.ParameterValue; 6 | 7 | import java.util.List; 8 | import java.util.function.Function; 9 | import java.util.function.Predicate; 10 | 11 | /** 12 | * @author Kanstantsin Shautsou 13 | */ 14 | public enum GitHubTagEnv implements GitHubEnv { 15 | NAME(GitHubTagCause::getTagName), 16 | SHORT_DESC(GitHubTagCause::getShortDescription), 17 | TITLE(GitHubTagCause::getTitle), 18 | URL((Function) c -> c.getHtmlUrl().toString()), 19 | HEAD_SHA(GitHubTagCause::getCommitSha), 20 | FULL_REF(GitHubTagCause::getFullRef), 21 | CAUSE_SKIP(GitHubTagCause::isSkip); 22 | 23 | public static final String PREFIX = "GITHUB_TAG_"; 24 | 25 | private Function fun; 26 | 27 | GitHubTagEnv(Function fun) { 28 | this.fun = c -> param(fun.apply(c)); 29 | } 30 | 31 | GitHubTagEnv(Predicate fun) { 32 | this.fun = c -> param(fun.test(c)); 33 | } 34 | 35 | @Override 36 | public void addParam(GitHubTagCause cause, List params) { 37 | params.add(fun.apply(cause)); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return PREFIX.concat(name()); 43 | } 44 | 45 | public static void getParams(GitHubTagCause cause, List params) { 46 | GitHubEnv.getParams(GitHubTagEnv.class, cause, params); 47 | GitHubEnv.getParams(GitHubRepoEnv.class, cause, params); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/tag/LocalRepoUpdater.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag; 2 | 3 | import org.kohsuke.github.GHTag; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.util.function.Function; 8 | 9 | /** 10 | * @author Kanstantsin Shautsou 11 | */ 12 | public class LocalRepoUpdater implements Function { 13 | private static final Logger LOGGER = LoggerFactory.getLogger(LocalRepoUpdater.class); 14 | private final GitHubTagRepository localRepo; 15 | 16 | private LocalRepoUpdater(GitHubTagRepository localRepo) { 17 | this.localRepo = localRepo; 18 | } 19 | 20 | public static LocalRepoUpdater updateLocalRepo(GitHubTagRepository localRepo) { 21 | return new LocalRepoUpdater(localRepo); 22 | } 23 | 24 | @Override 25 | public GHTag apply(GHTag remoteTag) { 26 | LOGGER.trace("Updating local branch repository with [{}]", remoteTag.getName()); 27 | localRepo.getTags().put(remoteTag.getName(), new GitHubTag(remoteTag)); 28 | 29 | return remoteTag; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/tag/events/GitHubTagEvent.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag.events; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubTagDecisionContext; 4 | import com.github.kostyasha.github.integration.tag.GitHubTagCause; 5 | import hudson.ExtensionPoint; 6 | import hudson.model.AbstractDescribableImpl; 7 | 8 | import edu.umd.cs.findbugs.annotations.CheckForNull; 9 | import edu.umd.cs.findbugs.annotations.NonNull; 10 | import java.io.IOException; 11 | 12 | /** 13 | * Different "events" that may want trigger run for tag. 14 | * 15 | * @author Kanstantsin Shautsou 16 | * @see com.github.kostyasha.github.integration.branch.events.GitHubBranchEvent 17 | */ 18 | public abstract class GitHubTagEvent extends AbstractDescribableImpl implements ExtensionPoint { 19 | 20 | /** 21 | * indicates that branch was created 22 | * 23 | * @return cause object. null when no influence (other events will be checked. 24 | * If cause.isSkip() == true, then other checks wouldn't influence. And triggering for this branch will be skipped. 25 | * If cause.isSkip() == false, indicates that branch build should be run. 26 | */ 27 | @CheckForNull 28 | public GitHubTagCause check(@NonNull GitHubTagDecisionContext context) throws IOException { 29 | return null; 30 | } 31 | 32 | @Override 33 | public GitHubTagEventDescriptor getDescriptor() { 34 | return (GitHubTagEventDescriptor) super.getDescriptor(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/tag/events/GitHubTagEventDescriptor.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag.events; 2 | 3 | import hudson.DescriptorExtensionList; 4 | import hudson.model.Descriptor; 5 | import jenkins.model.Jenkins; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public abstract class GitHubTagEventDescriptor extends Descriptor { 11 | public static DescriptorExtensionList all() { 12 | return Jenkins.getInstance().getDescriptorList(GitHubTagEvent.class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRBadgeAction.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubBadgeAction; 4 | 5 | /** 6 | * @author Kanstantsin Shautsou 7 | */ 8 | public class GitHubPRBadgeAction extends GitHubBadgeAction { 9 | 10 | private final int number; 11 | 12 | public GitHubPRBadgeAction(GitHubPRCause cause) { 13 | super(cause); 14 | this.number = cause.getNumber(); 15 | } 16 | 17 | @Override 18 | public String getIconFileName() { 19 | return null; 20 | } 21 | 22 | @Override 23 | public String getDisplayName() { 24 | return null; 25 | } 26 | 27 | @Override 28 | public String getUrlName() { 29 | return null; 30 | } 31 | 32 | public int getNumber() { 33 | return number; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRBuildListener.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Run; 5 | import hudson.model.TaskListener; 6 | import hudson.model.listeners.RunListener; 7 | import hudson.plugins.git.util.BuildData; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import edu.umd.cs.findbugs.annotations.NonNull; 12 | 13 | import static java.util.Objects.isNull; 14 | import static java.util.Objects.nonNull; 15 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghPRCauseFromRun; 16 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghPRTriggerFromRun; 17 | 18 | /** 19 | * Sets Pending build status before build run and manipulates Git's BuildData attached to job Action. 20 | * 21 | * @author Kanstantsin Shautsou 22 | */ 23 | @Extension 24 | public class GitHubPRBuildListener extends RunListener> { 25 | private static final Logger LOGGER = LoggerFactory.getLogger(GitHubPRBuildListener.class); 26 | 27 | @Override 28 | public void onCompleted(Run run, @NonNull TaskListener listener) { 29 | GitHubPRTrigger trigger = ghPRTriggerFromRun(run); 30 | if (isNull(trigger)) { 31 | return; 32 | } 33 | 34 | GitHubPRCause cause = ghPRCauseFromRun(run); 35 | 36 | if (nonNull(cause)) { 37 | //remove all BuildData, because it doesn't work right with pull requests now 38 | //TODO rework after git-client patching about BuildData usage 39 | run.getActions().removeAll(run.getActions(BuildData.class)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRLabel.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest; 2 | 3 | import com.google.common.base.Joiner; 4 | import hudson.Extension; 5 | import hudson.model.Describable; 6 | import hudson.model.Descriptor; 7 | import jenkins.model.Jenkins; 8 | import org.jenkinsci.Symbol; 9 | import org.kohsuke.stapler.DataBoundConstructor; 10 | 11 | import edu.umd.cs.findbugs.annotations.NonNull; 12 | import java.util.Arrays; 13 | import java.util.Collections; 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | import static java.util.Objects.nonNull; 18 | 19 | /** 20 | * Label object that contains user defined labels 21 | * 22 | * @author Alina Karpovich 23 | */ 24 | public class GitHubPRLabel implements Describable { 25 | private Set labels; 26 | 27 | @DataBoundConstructor 28 | public GitHubPRLabel(String labels) { 29 | this(new HashSet<>(Arrays.asList(labels.split("\n")))); 30 | } 31 | 32 | public GitHubPRLabel(Set labels) { 33 | this.labels = labels; 34 | } 35 | 36 | // for UI binding 37 | public String getLabels() { 38 | return Joiner.on("\n").skipNulls().join(labels); 39 | } 40 | 41 | @NonNull 42 | public Set getLabelsSet() { 43 | return nonNull(labels) ? labels : Collections.emptySet(); 44 | } 45 | 46 | public DescriptorImpl getDescriptor() { 47 | return (DescriptorImpl) Jenkins.getInstance().getDescriptor(GitHubPRLabel.class); 48 | } 49 | 50 | @Symbol("labels") 51 | @Extension 52 | public static class DescriptorImpl extends Descriptor { 53 | @NonNull 54 | @Override 55 | public String getDisplayName() { 56 | return "Labels"; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRPollingLogAction.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest; 2 | 3 | import com.github.kostyasha.github.integration.generic.GitHubPollingLogAction; 4 | import hudson.model.Job; 5 | import hudson.model.Run; 6 | 7 | /** 8 | * Link for project page, shows triggered polling log 9 | * 10 | * @author Alina Karpovich 11 | */ 12 | public class GitHubPRPollingLogAction extends GitHubPollingLogAction { 13 | public GitHubPRPollingLogAction(Run run) { 14 | super(run); 15 | } 16 | 17 | public GitHubPRPollingLogAction(Job job) { 18 | super(job); 19 | } 20 | 21 | @Override 22 | public String getPollingFileName() { 23 | return "github-pullrequest-polling.log"; 24 | } 25 | 26 | @Override 27 | public String getIconFileName() { 28 | return "clipboard.png"; 29 | } 30 | 31 | @Override 32 | public String getDisplayName() { 33 | return "GitHub PR Polling Log"; 34 | } 35 | 36 | @Override 37 | public String getUrlName() { 38 | return "github-pr-polling"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMode.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest; 2 | 3 | /** 4 | * Trigger modes 5 | * 6 | * @author Kanstantsin Shautsou 7 | */ 8 | public enum GitHubPRTriggerMode { 9 | CRON("Cron with Persisted Data"), 10 | HEAVY_HOOKS("Hooks with Persisted Data"), 11 | HEAVY_HOOKS_CRON("Hooks plus Cron with Persisted Data"), 12 | LIGHT_HOOKS("NOT SUPPORTED: Non-persistent Hooks"); 13 | 14 | private final String description; 15 | 16 | GitHubPRTriggerMode(String description) { 17 | this.description = description; 18 | } 19 | 20 | public String getDescription() { 21 | return description; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/dsl/context/GitHubPRTriggerModeDslContext.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.dsl.context; 2 | 3 | import javaposse.jobdsl.dsl.Context; 4 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRTriggerMode; 5 | 6 | /** 7 | * @author lanwen (Merkushev Kirill) 8 | */ 9 | public class GitHubPRTriggerModeDslContext implements Context { 10 | private GitHubPRTriggerMode mode = GitHubPRTriggerMode.CRON; 11 | 12 | public void cron() { 13 | mode = GitHubPRTriggerMode.CRON; 14 | } 15 | 16 | public void heavyHooks() { 17 | mode = GitHubPRTriggerMode.HEAVY_HOOKS; 18 | } 19 | 20 | public void heavyHooksCron() { 21 | mode = GitHubPRTriggerMode.HEAVY_HOOKS_CRON; 22 | } 23 | 24 | public GitHubPRTriggerMode mode() { 25 | return mode; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/dsl/context/publishers/GitHubPRStatusPublisherDslContext.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.dsl.context.publishers; 2 | 3 | import javaposse.jobdsl.dsl.Context; 4 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRMessage; 5 | import org.kohsuke.github.GHCommitState; 6 | 7 | /** 8 | * @author lanwen (Merkushev Kirill) 9 | */ 10 | public class GitHubPRStatusPublisherDslContext implements Context { 11 | 12 | private GitHubPRMessage message; 13 | private GHCommitState state; 14 | 15 | public void message(String content) { 16 | message = new GitHubPRMessage(content); 17 | } 18 | 19 | public void unstableAsError() { 20 | this.state = GHCommitState.ERROR; 21 | } 22 | 23 | public GHCommitState unstableAs() { 24 | return state; 25 | } 26 | 27 | public GitHubPRMessage message() { 28 | return message; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/dsl/context/steps/GitHubPRStatusStepDslContext.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.dsl.context.steps; 2 | 3 | import javaposse.jobdsl.dsl.Context; 4 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRMessage; 5 | 6 | public class GitHubPRStatusStepDslContext implements Context { 7 | private GitHubPRMessage message; 8 | 9 | public void message(String content) { 10 | message = new GitHubPRMessage(content); 11 | } 12 | 13 | public GitHubPRMessage message() { 14 | return message; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/events/GitHubPREventDescriptor.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events; 2 | 3 | import hudson.DescriptorExtensionList; 4 | import hudson.model.Descriptor; 5 | import jenkins.model.Jenkins; 6 | 7 | /** 8 | * @author Kanstantsin Shautsou 9 | */ 10 | public abstract class GitHubPREventDescriptor extends Descriptor { 11 | // public boolean isApplicable(Class type) { 12 | // return true; 13 | // } 14 | 15 | public static DescriptorExtensionList all() { 16 | return Jenkins.getInstance().getDescriptorList(GitHubPREvent.class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/trigger/NewPRInterruptCause.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger; 2 | 3 | import jenkins.model.CauseOfInterruption; 4 | 5 | /** 6 | * @author Kanstantsin Shautsou 7 | */ 8 | public class NewPRInterruptCause extends CauseOfInterruption { 9 | @Override 10 | public String getShortDescription() { 11 | return "Newer PR will be scheduled."; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/trigger/check/BranchRestrictionFilter.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger.check; 2 | 3 | import com.google.common.base.Predicate; 4 | import com.google.common.base.Predicates; 5 | import org.jenkinsci.plugins.github.pullrequest.restrictions.GitHubPRBranchRestriction; 6 | import org.jenkinsci.plugins.github.pullrequest.utils.LoggingTaskListenerWrapper; 7 | import org.kohsuke.github.GHPullRequest; 8 | 9 | import static java.util.Objects.isNull; 10 | 11 | /** 12 | * @author lanwen (Merkushev Kirill) 13 | */ 14 | public class BranchRestrictionFilter implements Predicate { 15 | private final LoggingTaskListenerWrapper logger; 16 | private final GitHubPRBranchRestriction branchRestriction; 17 | 18 | private BranchRestrictionFilter(LoggingTaskListenerWrapper logger, GitHubPRBranchRestriction branchRestriction) { 19 | this.logger = logger; 20 | this.branchRestriction = branchRestriction; 21 | } 22 | 23 | public static Predicate withBranchRestriction( 24 | LoggingTaskListenerWrapper logger, GitHubPRBranchRestriction branchRestriction) { 25 | 26 | if (isNull(branchRestriction)) { 27 | return Predicates.alwaysTrue(); 28 | } 29 | 30 | return new BranchRestrictionFilter(logger, branchRestriction); 31 | } 32 | 33 | @Override 34 | public boolean apply(GHPullRequest remotePR) { 35 | if (!branchRestriction.isBranchBuildAllowed(remotePR)) { 36 | logger.info("Skipping [#{} {}] because of branch restriction", remotePR.getNumber(), remotePR.getTitle()); 37 | return false; 38 | } 39 | 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/trigger/check/LocalRepoUpdater.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger.check; 2 | 3 | import com.google.common.base.Function; 4 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRPullRequest; 5 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository; 6 | import org.kohsuke.github.GHPullRequest; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import static org.kohsuke.github.GHIssueState.CLOSED; 11 | import static org.kohsuke.github.GHIssueState.OPEN; 12 | 13 | /** 14 | * @author lanwen (Merkushev Kirill) 15 | */ 16 | public class LocalRepoUpdater implements Function, java.util.function.Function { 17 | private static final Logger LOGGER = LoggerFactory.getLogger(LocalRepoUpdater.class); 18 | private final GitHubPRRepository localRepo; 19 | 20 | private LocalRepoUpdater(GitHubPRRepository localRepo) { 21 | this.localRepo = localRepo; 22 | } 23 | 24 | public static LocalRepoUpdater updateLocalRepo(GitHubPRRepository localRepo) { 25 | return new LocalRepoUpdater(localRepo); 26 | } 27 | 28 | @Override 29 | public GHPullRequest apply(GHPullRequest remotePR) { 30 | if (remotePR.getState() == OPEN) { 31 | localRepo.getPulls().put(remotePR.getNumber(), new GitHubPRPullRequest(remotePR)); 32 | } else if (remotePR.getState() == CLOSED) { 33 | localRepo.getPulls().remove(remotePR.getNumber()); // don't store 34 | } 35 | 36 | return remotePR; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/trigger/check/SkipFirstRunForPRFilter.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger.check; 2 | 3 | import com.google.common.base.Predicate; 4 | import hudson.model.TaskListener; 5 | import org.kohsuke.github.GHPullRequest; 6 | 7 | /** 8 | * @author lanwen (Merkushev Kirill) 9 | */ 10 | public class SkipFirstRunForPRFilter implements Predicate { 11 | private final TaskListener logger; 12 | private final boolean skipFirstRun; 13 | 14 | private SkipFirstRunForPRFilter(TaskListener logger, boolean skipFirstRun) { 15 | this.logger = logger; 16 | this.skipFirstRun = skipFirstRun; 17 | } 18 | 19 | public static Predicate ifSkippedFirstRun(TaskListener logger, boolean skipFirstRun) { 20 | return new SkipFirstRunForPRFilter(logger, skipFirstRun); 21 | } 22 | 23 | @Override 24 | public boolean apply(GHPullRequest remotePR) { 25 | if (skipFirstRun) { 26 | logger.getLogger().println(String.format("Skipping first run for PR #%s", remotePR.getNumber())); 27 | return false; 28 | } 29 | 30 | return true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/trigger/check/SkippedCauseFilter.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger.check; 2 | 3 | import com.google.common.base.Predicate; 4 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRCause; 5 | import org.jenkinsci.plugins.github.pullrequest.utils.LoggingTaskListenerWrapper; 6 | 7 | /** 8 | * @author lanwen (Merkushev Kirill) 9 | */ 10 | public class SkippedCauseFilter implements Predicate { 11 | private final LoggingTaskListenerWrapper listener; 12 | 13 | public SkippedCauseFilter(LoggingTaskListenerWrapper listener) { 14 | this.listener = listener; 15 | } 16 | 17 | @Override 18 | public boolean apply(GitHubPRCause cause) { 19 | if (cause.isSkip()) { 20 | listener.debug("Skipping PR #{}", cause.getNumber()); 21 | return false; 22 | } else { 23 | listener.debug("Prepare to trigger build for PR #{}, because {}", cause.getNumber(), cause.getReason()); 24 | return true; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/utils/PublisherErrorHandler.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.utils; 2 | 3 | import hudson.Extension; 4 | import hudson.model.AbstractDescribableImpl; 5 | import hudson.model.Descriptor; 6 | import hudson.model.Result; 7 | import hudson.model.Run; 8 | import hudson.util.ListBoxModel; 9 | import org.jenkinsci.Symbol; 10 | import org.kohsuke.stapler.DataBoundConstructor; 11 | 12 | import edu.umd.cs.findbugs.annotations.NonNull; 13 | 14 | /** 15 | * Allows to change build result to specified value if there was publisher error. 16 | * 17 | * @author Alina Karpovich 18 | */ 19 | public class PublisherErrorHandler extends AbstractDescribableImpl { 20 | 21 | private Result buildStatus; 22 | 23 | @DataBoundConstructor 24 | public PublisherErrorHandler(Result buildStatus) { 25 | this.buildStatus = buildStatus; 26 | } 27 | 28 | public Result getBuildStatus() { 29 | return buildStatus; 30 | } 31 | 32 | public Result markBuildAfterError(Run run) { 33 | run.setResult(buildStatus); 34 | return buildStatus; 35 | } 36 | 37 | @Symbol("statusOnPublisherError") 38 | @Extension 39 | public static class DescriptorImpl extends Descriptor { 40 | @NonNull 41 | @Override 42 | public String getDisplayName() { 43 | return "Set build status if publisher failed"; 44 | } 45 | 46 | public ListBoxModel doFillBuildStatusItems() { 47 | ListBoxModel items = new ListBoxModel(); 48 | items.add(Result.UNSTABLE.toString()); 49 | items.add(Result.FAILURE.toString()); 50 | return items; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/utils/StatusVerifier.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.utils; 2 | 3 | import hudson.Extension; 4 | import hudson.model.AbstractDescribableImpl; 5 | import hudson.model.Descriptor; 6 | import hudson.model.Result; 7 | import hudson.model.Run; 8 | import hudson.util.ListBoxModel; 9 | import org.jenkinsci.Symbol; 10 | import org.kohsuke.stapler.DataBoundConstructor; 11 | 12 | /** 13 | * Checks build result and allows run for publishers only for builds with specified result. 14 | * 15 | * @author Alina Karpovich 16 | */ 17 | public class StatusVerifier extends AbstractDescribableImpl { 18 | 19 | private Result buildStatus; 20 | 21 | @DataBoundConstructor 22 | public StatusVerifier(Result buildStatus) { 23 | this.buildStatus = buildStatus; 24 | } 25 | 26 | public boolean isRunAllowed(Run run) { 27 | return run.getResult().isBetterOrEqualTo(buildStatus); 28 | } 29 | 30 | public Result getBuildStatus() { 31 | return buildStatus; 32 | } 33 | 34 | @Symbol("allowRunOnStatus") 35 | @Extension 36 | public static class DescriptorImpl extends Descriptor { 37 | @Override 38 | public String getDisplayName() { 39 | return "Allow run only for specified status"; 40 | } 41 | 42 | public ListBoxModel doFillBuildStatusItems() { 43 | ListBoxModel items = new ListBoxModel(); 44 | items.add(Result.SUCCESS.toString()); 45 | items.add(Result.UNSTABLE.toString()); 46 | items.add(Result.FAILURE.toString()); 47 | return items; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/webhook/GitHubPRRepositoryNameContributor.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.webhook; 2 | 3 | import com.cloudbees.jenkins.GitHubRepositoryName; 4 | import com.cloudbees.jenkins.GitHubRepositoryNameContributor; 5 | import hudson.Extension; 6 | import hudson.model.Job; 7 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger; 8 | 9 | import java.util.Collection; 10 | 11 | import static java.util.Objects.nonNull; 12 | import static org.jenkinsci.plugins.github.pullrequest.utils.JobHelper.ghPRTriggerFromJob; 13 | 14 | /** 15 | * PR Trigger tied to GitHub repo. Report it for GitHub doReRegister(). 16 | * 17 | * @author Kanstantsin Shautsou 18 | */ 19 | @Extension 20 | public class GitHubPRRepositoryNameContributor extends GitHubRepositoryNameContributor { 21 | @Override 22 | public void parseAssociatedNames(Job job, Collection result) { 23 | final GitHubPRTrigger gitHubPRTrigger = ghPRTriggerFromJob(job); 24 | if (nonNull(gitHubPRTrigger)) { 25 | result.add(gitHubPRTrigger.getRepoFullName(job)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/java/org/jenkinsci/plugins/github/pullrequest/webhook/PullRequestInfo.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.webhook; 2 | 3 | /** 4 | * Bean class to store main info from payload of webhook 5 | * 6 | * @author lanwen (Merkushev Kirill) 7 | */ 8 | public class PullRequestInfo { 9 | private final String repo; 10 | private final int num; 11 | private String target; 12 | 13 | public PullRequestInfo(String repo, int num) { 14 | this(repo, num, null); 15 | } 16 | 17 | public PullRequestInfo(String repo, int num, String target) { 18 | this.repo = repo; 19 | this.num = num; 20 | this.target = target; 21 | } 22 | 23 | public String getRepo() { 24 | return repo; 25 | } 26 | 27 | public int getNum() { 28 | return num; 29 | } 30 | 31 | public String getTarget() { 32 | return target; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranch/index.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.GitHubBranch 2 | 3 | a(href: my.htmlUrl) { 4 | img(src: rootURL + my.iconFileName, width: "16", height: "16") 5 | text(my.name) 6 | } 7 | 8 | table(width: "1000px") { 9 | tr() { 10 | td("SHA1: " + my.getCommitSha()) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchBadgeAction/badge.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.GitHubBranchBadgeAction 2 | 3 | import lib.FormTagLib 4 | import lib.LayoutTagLib 5 | import com.github.kostyasha.github.integration.branch.GitHubBranch 6 | 7 | def l = namespace(LayoutTagLib); 8 | def f = namespace(FormTagLib); 9 | def j = namespace("jelly:core"); 10 | 11 | a(href: "${my.htmlUrl}/tree/${my.branchName}") { 12 | img(src: "${rootURL}${GitHubBranch.iconFileName}", 13 | title: my.title, 14 | width: "16", 15 | height: "16" 16 | ) 17 | text("${my.branchName}") 18 | } 19 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchCause/description.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.GitHubBranchCause 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | if (my.htmlUrl != null) { 8 | text("GitHub branch ") 9 | a(href: "${my.htmlUrl}/tree/${my.branchName}") { 10 | text("${my.branchName}") 11 | } 12 | text(": ${my.reason}") 13 | } else { 14 | text("Branch deleted") 15 | } 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchPollingLogAction/index.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.GitHubBranchPollingLogAction 2 | 3 | import lib.FormTagLib 4 | import lib.LayoutTagLib 5 | 6 | def f = namespace(FormTagLib); 7 | def l = namespace(LayoutTagLib); 8 | def t = namespace("/lib/hudson") 9 | def st = namespace("jelly:stapler"); 10 | def j = namespace("jelly:core"); 11 | 12 | def context = my.job ? my.job : my.run 13 | 14 | l.layout(title: my.displayName) { 15 | st.include(page: "sidepanel", it: context) 16 | l.main_panel() { 17 | h1(my.displayName); 18 | // h4("Polling log of last attempt of build.") 19 | l.rightspace() { 20 | a(href: "pollingLog"){ 21 | l.icon(class: "icon-document icon-md") 22 | text("View as plain text") 23 | } 24 | } 25 | 26 | if (my.logExists) { 27 | pre() { 28 | j.whitespace() { 29 | my.writePollingLogTo(output); 30 | } 31 | } 32 | } else { 33 | text("There is no logs so far."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTrigger/help-abortRunning.html: -------------------------------------------------------------------------------- 1 | If selected, when a new PR build is triggered, if there are already running/building 2 | builds/runs for that PR on the executors, they'll be aborted in favor of this most recent build. 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTrigger/help-events.html: -------------------------------------------------------------------------------- 1 |
2 | GitHub events or statuses that should or should not trigger a build for branch. 3 |
4 | The specified events will be checked in order, and the first to match will 5 | be used, so be sure to put events/statuses that should prevent triggering a 6 | build first in order. 7 |
8 | If you want to skip PR, you must place skip events firstly. 9 |
10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTrigger/help-skipFirstRun.html: -------------------------------------------------------------------------------- 1 |
2 | If selected, older, pre-existing PRs will be skipped on the first run of the 3 | persistence-based check, and will be marked as seen. Any changes to those PRs after the first 4 | check will be treated normally, triggering builds as configured. 5 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTrigger/help-triggerMode.html: -------------------------------------------------------------------------------- 1 |
2 | Trigger modes. 3 |
    4 |
  • Cron: Checks for PRs to build periodically.
  • 5 |
  • Hooks: Listens for GitHub webhook events.
  • 6 |
  • Hooks plus Cron: Not fully supported - combines webhooks and cron checks.
  • 7 |
  • Transient Hooks: Not fully supported - listens for GitHub webhook events, does not preserve state for pull requests across runs or Jenkins restarts, etc.
  • 8 |
9 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchCommitEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.events.impl.GitHubBranchCommitEvent 2 | 3 | import com.github.kostyasha.github.integration.branch.events.impl.GitHubBranchCommitEvent 4 | import lib.FormTagLib 5 | 6 | def f = namespace(FormTagLib) 7 | 8 | if (instance == null) { 9 | instance = new GitHubBranchCommitEvent() 10 | } 11 | 12 | f.block { 13 | table(style: 'width:100%; margin-left: 5px;') { 14 | f.entry() { 15 | f.hetero_list(name: "checks", 16 | items: instance.checks, 17 | descriptors: descriptor.getEventDescriptors(), 18 | hasHeader: true 19 | ) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchCreatedEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.events.impl.GitHubBranchCreatedEvent 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/GitHubBranchRestrictionFilter/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.events.impl.GitHubBranchRestrictionFilter 2 | 3 | import lib.FormTagLib 4 | import lib.LayoutTagLib 5 | 6 | def l = namespace(LayoutTagLib); 7 | def f = namespace(FormTagLib); 8 | def j = namespace("jelly:core"); 9 | 10 | f.entry(field: "exclude", title: "Exclude branches that match criteria?") { 11 | f.checkbox() 12 | } 13 | 14 | f.entry(field: "matchAsPattern", title: "Match branches against pattern criteria?") { 15 | f.checkbox() 16 | } 17 | 18 | f.entry(title: "Branch Names or Patterns") { 19 | f.textarea(field: "matchCriteriaStr") 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.events.impl.commitchecks.impl.GitHubBranchCommitMessageCheck 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(field: "exclude", title: "Exclude commits that match criteria?") { 8 | f.checkbox() 9 | } 10 | 11 | f.entry(title: _("Message Patterns"), field: "matchCriteria") { 12 | f.expandableTextbox() 13 | } 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck/help-matchCriteria.html: -------------------------------------------------------------------------------- 1 |
2 | Inclusion/Exclusion uses pattern matching 3 |
4 |
5 | .*\[maven-release-plugin\].* 6 |
7 | The example above illustrates that if only revisions with "[maven-release-plugin]" message in first comment line have 8 | been committed to the SCM a build will not occur. 9 |
10 |
11 | You can create more complex patterns using embedded flag expressions. 12 |
13 |
14 | (?s).*FOO.* 15 |
16 | This example will search FOO message in all comment lines. 17 |
18 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/branch/events/impl/commitchecks/impl/GitHubBranchCommitMessageCheck/help.html: -------------------------------------------------------------------------------- 1 |
2 | If set, the plugin will only build revisions commited with messages that match the pattern. If 'skip' is 3 | selected, any revisions with matching messages will be ignored. 4 |
5 |
6 | This can be used to exclude commits done by the build itself from triggering another build, assuming the build 7 | server commits the change with a distinct message. 8 |
9 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/generic/errors/GitHubErrorsAction/jobMain.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.errors.GitHubErrorsAction 2 | 3 | def t = namespace("/lib/hudson") 4 | def st = namespace("jelly:stapler"); 5 | 6 | if (from?.hasVisibleErrors()) { 7 | // indent like in hudson/model/AbstractProject/main.jelly 8 | table(style: "margin-left:1em;") { 9 | t.summary(icon: "warning.png") { 10 | b(from.description) 11 | br() 12 | from.getErrorsSnapshot().eachWithIndex() { error, index -> 13 | if (error.isVisible()) { 14 | b(++index + " " + error.title) 15 | div(style: "margin-left:2em") { 16 | raw(error.getHtmlDescription()) 17 | } 18 | st.include(page: "index.jelly", it: error, optional: true) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/generic/repoprovider/GitHubPluginRepoProvider/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider 2 | 3 | import com.github.kostyasha.github.integration.generic.repoprovider.GitHubPluginRepoProvider 4 | import lib.FormTagLib 5 | 6 | def f = namespace(FormTagLib); 7 | def st = namespace("jelly:stapler") 8 | 9 | if (instance == null) { 10 | instance = new GitHubPluginRepoProvider(); 11 | } 12 | 13 | f.entry(title: "Cache connection?", field: "cacheConnection") { 14 | f.checkbox(default: false) 15 | } 16 | 17 | f.entry(title: "Manage hooks", field: "manageHooks") { 18 | f.checkbox() 19 | } 20 | 21 | f.entry(title: "Repository requested permission", field: "repoPermission") { 22 | f.enum() { 23 | text(my.name()) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/generic/repoprovider/GitHubPluginRepoProvider/help-cacheConnection.html: -------------------------------------------------------------------------------- 1 | Old trigger behaviour when connection resolved first from global settings and then used locally. 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/generic/repoprovider/GitHubPluginRepoProvider/help-manageHooks.html: -------------------------------------------------------------------------------- 1 | Allow disable registering hooks even if it specified in global settings. -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/generic/repoprovider/GitHubPluginRepoProvider/help-repoPermission.html: -------------------------------------------------------------------------------- 1 | ADMIN, PUSH or PULL repository permission required for choosing connection from 2 | `GitHub Plugin` `GitHub Server Configs`. 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/GitHubBranchBuildStrategy/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.GitHubBranchBuildStrategy 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/GitHubBranchBuildStrategy/help.html: -------------------------------------------------------------------------------- 1 |
2 | Ensures that skipped causes are honored on new branch item creation 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/action/GitHubSCMSourcesReposAction/index.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.action.GitHubSCMSourcesReposAction 2 | 3 | import com.github.kostyasha.github.integration.branch.GitHubBranchCause 4 | import hudson.model.Item 5 | import lib.FormTagLib 6 | import lib.LayoutTagLib 7 | 8 | println("test") 9 | f.entry(title: "test") 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/handler/GitHubBranchHandler/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.handler.GitHubBranchHandler 2 | 3 | import com.github.kostyasha.github.integration.branch.events.GitHubBranchEventDescriptor 4 | import com.github.kostyasha.github.integration.multibranch.handler.GitHubBranchHandler 5 | import lib.FormTagLib 6 | 7 | def f = namespace(FormTagLib); 8 | def st = namespace("jelly:stapler") 9 | 10 | if (instance == null) { 11 | instance = new GitHubBranchHandler(); 12 | } 13 | 14 | f.entry(title: _("Trigger Events"), help: descriptor.getHelpFile('events')) { 15 | f.hetero_list(name: "events", 16 | items: instance.events, 17 | descriptors: GitHubBranchEventDescriptor.all(), 18 | hasHeader: true 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/handler/GitHubPRHandler/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.handler.GitHubPRHandler 2 | 3 | import com.github.kostyasha.github.integration.multibranch.handler.GitHubPRHandler 4 | import lib.FormTagLib 5 | import org.jenkinsci.plugins.github.pullrequest.events.GitHubPREventDescriptor 6 | 7 | def f = namespace(FormTagLib); 8 | def st = namespace("jelly:stapler") 9 | 10 | if (instance == null) { 11 | instance = new GitHubPRHandler(); 12 | } 13 | 14 | f.entry(title: _("Trigger Events"), help: descriptor.getHelpFile('events')) { 15 | f.hetero_list(name: "events", 16 | items: instance.events, 17 | descriptors: GitHubPREventDescriptor.all(), 18 | hasHeader: true 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/handler/GitHubTagHandler/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.handler.GitHubTagHandler 2 | 3 | import com.github.kostyasha.github.integration.tag.events.GitHubTagEventDescriptor 4 | import com.github.kostyasha.github.integration.multibranch.handler.GitHubTagHandler 5 | import lib.FormTagLib 6 | 7 | def f = namespace(FormTagLib); 8 | def st = namespace("jelly:stapler") 9 | 10 | if (instance == null) { 11 | instance = new GitHubTagHandler(); 12 | } 13 | 14 | f.entry(title: _("Trigger Events"), help: descriptor.getHelpFile('events')) { 15 | f.hetero_list(name: "events", 16 | items: instance.events, 17 | descriptors: GitHubTagEventDescriptor.all(), 18 | hasHeader: true 19 | ) 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/repoprovider/GitHubPluginRepoProvider2/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.repoprovider.GitHubPluginRepoProvider2 2 | 3 | import com.github.kostyasha.github.integration.multibranch.repoprovider.GitHubPluginRepoProvider2 4 | import lib.FormTagLib 5 | 6 | def f = namespace(FormTagLib); 7 | def st = namespace("jelly:stapler") 8 | 9 | if (instance == null) { 10 | instance = new GitHubPluginRepoProvider2(); 11 | } 12 | 13 | f.entry(title: "Cache connection?", field: "cacheConnection") { 14 | f.checkbox(default: false) 15 | } 16 | 17 | f.entry(title: "Manage hooks", field: "manageHooks") { 18 | f.checkbox() 19 | } 20 | 21 | f.entry(title: "Repository requested permission", field: "repoPermission") { 22 | f.enum() { 23 | text(my.name()) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/multibranch/scm/AsIsGitSCMFactory/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.multibranch.scm.AsIsGitSCMFactory 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.property(name: "gitSCM") 8 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/tag/GitHubTag/index.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag.GitHubTag 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/tag/GitHubTagCause/description.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag.GitHubTagCause 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | if (my.htmlUrl != null) { 8 | text("GitHub tag ") 9 | a(href: "${my.htmlUrl}") { 10 | text("${my.tagName}") 11 | } 12 | text(": ${my.reason}") 13 | } else{ 14 | text("Tag deleted") 15 | } 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/tag/events/impl/GitHubTagCreatedEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag.events.impl.GitHubTagCreatedEvent 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/com/github/kostyasha/github/integration/tag/events/impl/GitHubTagRestrictionFilter/config.groovy: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.tag.events.impl.GitHubTagRestrictionFilter 2 | 3 | import lib.FormTagLib 4 | import lib.LayoutTagLib 5 | 6 | def l = namespace(LayoutTagLib); 7 | def f = namespace(FormTagLib); 8 | def j = namespace("jelly:core"); 9 | 10 | f.entry(field: "exclude", title: "Exclude tags that match criteria?") { 11 | f.checkbox() 12 | } 13 | 14 | f.entry(field: "matchAsPattern", title: "Match tags against pattern criteria?") { 15 | f.checkbox() 16 | } 17 | 18 | f.entry(title: "Tags Names or Patterns") { 19 | f.textarea(field: "matchCriteriaStr") 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 | 2 |
3 | GitHub Integration Plugin for Jenkins 4 |
5 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRBadgeAction/badge.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRBadgeAction 2 | 3 | import lib.FormTagLib 4 | import lib.LayoutTagLib 5 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRPullRequest 6 | 7 | def l = namespace(LayoutTagLib); 8 | def f = namespace(FormTagLib); 9 | def j = namespace("jelly:core"); 10 | 11 | a(href: my.htmlUrl) { 12 | img(src: "${rootURL}${GitHubPRPullRequest.iconFileName}", 13 | title: my.title, 14 | width: "16", 15 | height: "16" 16 | ) 17 | text("#${my.number}") 18 | } 19 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRBuildChooser/config.groovy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KostyaSha/github-integration-plugin/50adabf6a628fd03c532224a187221899d8d1930/github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRBuildChooser/config.groovy -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRBuildChooser/help.html: -------------------------------------------------------------------------------- 1 |
2 | TODO Git build chooser strategy 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRCause/description.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRCause 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | if (my.htmlUrl != null) { 8 | text("GitHub PR ") 9 | a(href: "${my.htmlUrl}") { 10 | text("#${my.number}") 11 | } 12 | text(": ${my.reason}") 13 | } else { 14 | text("GitHub PR deleted") 15 | } 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRLabel/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRLabel 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Labels"), field: "labels") { 8 | f.expandableTextbox() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRLabel/help-labels.html: -------------------------------------------------------------------------------- 1 |

2 | Every new label on new line 3 |

-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRLabel/help.html: -------------------------------------------------------------------------------- 1 |
2 | Help page for GitHubPRLabel class. Not used anywhere? 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRMessage/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRMessage 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _('Content'), field: 'content') { 8 | f.expandableTextbox() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRMessage/help-content.html: -------------------------------------------------------------------------------- 1 |
2 | Message content that will be posted. Support core variable expansion i.e. ${WORKSPACE}.
3 | If token-macro plugin enabled, then support token expansion.
4 | If email-ext plugin enabled, then support expanding groovy templates with ${SCRIPT, path="template.groovy"}. 5 |
6 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRPollingLogAction/index.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRPollingLogAction 2 | 3 | import lib.FormTagLib 4 | import lib.LayoutTagLib 5 | 6 | def f = namespace(FormTagLib); 7 | def l = namespace(LayoutTagLib); 8 | def t = namespace("/lib/hudson") 9 | def st = namespace("jelly:stapler"); 10 | def j = namespace("jelly:core"); 11 | 12 | def context = my.job ? my.job : my.run 13 | 14 | l.layout(title: my.displayName) { 15 | st.include(page: "sidepanel", it: context) 16 | l.main_panel() { 17 | h1(my.displayName); 18 | // h4("Polling log of last attempt of build.") 19 | l.rightspace() { 20 | a(href: "pollingLog"){ 21 | l.icon(class: "icon-document icon-md") 22 | text("View as plain text") 23 | } 24 | } 25 | 26 | if (my.logExists) { 27 | pre() { 28 | j.whitespace() { 29 | my.writePollingLogTo(output); 30 | } 31 | } 32 | } else { 33 | text("There is no logs so far."); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRPullRequest/index.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRPullRequest 2 | 3 | import com.google.common.base.Joiner 4 | 5 | a(href: my.htmlUrl) { 6 | img(src: rootURL + my.iconFileName, width: "16", height: "16") 7 | text(" #" + my.number + ": " + my.title) 8 | } 9 | 10 | table(width: "1000px") { 11 | tr() { 12 | td("Head SHA: " + my.headSha) 13 | td("Author: " + my.userLogin) 14 | td("Issue updated at " + my.issueUpdatedAt) 15 | } 16 | tr() { 17 | td("Source branch: " + my.headRef) 18 | td("Author's email: " + my.userEmail) 19 | td("PR updated at " + my.prUpdatedAt) 20 | } 21 | tr() { 22 | td("Target branch: " + my.baseRef) 23 | td(my.mergeable ? "PR mergeable " : "PR NOT mergeable") 24 | td("Last commented at " + my.lastCommentCreatedAt) 25 | } 26 | tr() { 27 | def labels = (my.labels) ? Joiner.on(", ").join((List) my.labels.collect { x -> "\"" + x + "\"" }) : "none" 28 | td(colspan: 3, "Labels: " + labels) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/global.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.GitHubPRTrigger 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.section(title: _(descriptor.displayName)) { 8 | f.entry(title: _("Published Jenkins URL"), field: "publishedURL") { 9 | f.textbox() 10 | } 11 | 12 | f.entry(title: "Actualise local repo on factory creation", field: "actualiseOnFactory") { 13 | f.checkbox(default: false) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-abortRunning.html: -------------------------------------------------------------------------------- 1 | If selected, when a new PR build is triggered, if there are already running/building 2 | builds/runs for that PR on the executors, they'll be aborted in favor of this most recent build. 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-branchRestriction.html: -------------------------------------------------------------------------------- 1 |
2 | Limit job run to certain branch matches. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-cacheSize.html: -------------------------------------------------------------------------------- 1 |
2 | OkHttp connector disk cache size in MB. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-cancelQueued.html: -------------------------------------------------------------------------------- 1 |
2 | If selected, when a new PR build is triggered, if there are already pending 3 | builds for that PR in the queue, they'll be removed from the queue in favor 4 | of this most recent build. 5 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-events.html: -------------------------------------------------------------------------------- 1 |
2 | GitHub events or statuses that should or should not trigger a build of a pull request. 3 |
4 | The specified events will be checked in order, and the first to match will 5 | be used, so be sure to put events/statuses that should prevent triggering a 6 | build first in order. 7 |
8 | For performance reasons, "Pull Request Opened" should go before other 9 | events that require more detailed checking of the pull request, such as 10 | "Comment Matched to Pattern". But if you want to skip PR, you must place skip events firstly. 11 |
12 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-preStatus.html: -------------------------------------------------------------------------------- 1 |
2 | Updates the GitHub pull request's status to PENDING once the build for that pull request has been queued to run. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-skipFirstRun.html: -------------------------------------------------------------------------------- 1 |
2 | If selected, older, pre-existing PRs will be skipped on the first run of the 3 | persistence-based check, and will be marked as seen. Any changes to those PRs after the first 4 | check will be treated normally, triggering builds as configured. 5 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-triggerMode.html: -------------------------------------------------------------------------------- 1 |
2 | Trigger modes. 3 |
    4 |
  • Cron: Checks for PRs to build periodically.
  • 5 |
  • Hooks: Listens for GitHub webhook events.
  • 6 |
  • Hooks plus Cron: Not fully supported - combines webhooks and cron checks.
  • 7 |
  • Transient Hooks: Not fully supported - listens for GitHub webhook events, does not preserve state for pull requests across runs or Jenkins restarts, etc.
  • 8 |
9 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-useGitHubHooks.html: -------------------------------------------------------------------------------- 1 |
2 | Not implemented yet!
3 | Whether to use GitHub hooks instead of cron runs. 4 |
5 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help-userRestriction.html: -------------------------------------------------------------------------------- 1 |
2 | Adds ability to restrict who is allowed to run and whitelist users/orgs. 3 | Users can be updated with special comment from allowed users/orgs. 4 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTrigger/help.html: -------------------------------------------------------------------------------- 1 |
2 | Trigger that integrates with GitHub Pull Requests and Issues activities and launches runs in response. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/builders/GitHubPRStatusBuilder/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.builders.GitHubPRStatusBuilder 2 | 3 | import lib.FormTagLib 4 | import org.jenkinsci.plugins.github.pullrequest.builders.GitHubPRStatusBuilder 5 | 6 | def f = namespace(FormTagLib); 7 | 8 | // Stapler doesn't produce default values, so recreate object 9 | if (instance == null) { 10 | instance = new GitHubPRStatusBuilder() 11 | } 12 | 13 | f.entry(title: _("Build status message")) { 14 | f.property(field: "statusMessage") 15 | } 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRCloseEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers when a pull request is closed. Works only when 3 | pull request was opened and closed between persistence-based trigger runs. 4 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRCommentEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRCommentEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Comment Pattern"), field: "comment") { 8 | f.textbox() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRCommentEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers when a comment matching the pattern is posted in a pull request.
3 | For example Test ([A-Za-z0-9 ,!]+) tags please. 4 |
5 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRCommitEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers when a previously built pull request's hash has changed from the 3 | previous state (i.e., a new commit is pushed, or force-pushed). 4 |
5 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRDescriptionEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRDescriptionEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Skip build phrase"), field: "skipMsg") { 8 | f.textbox() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRDescriptionEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | If given, don't build a pull request if its description contains the given string. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelAddedEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRLabelAddedEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry() { 8 | f.property(field: "label") 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelAddedEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | Triggers run when label is added to pull request. 7 | Set of labels is considered added only when at least one label of set was newly added 8 | (was not saved in local PR previously) AND every label of set exists on remote PR now. 9 |
10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelExistsEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRLabelExistsEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(field: "skip", title: "Skip pull requests with existing label(s)?") { 8 | f.checkbox() 9 | } 10 | 11 | f.entry() { 12 | f.property(field: "label") 13 | } 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelExistsEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers when all the given labels are on a pull request, or blocks triggering 3 | if all the given labels are on a pull request. 4 |
5 | NOTE: This can cause infinite triggers of pull requests 6 | when the skip option isn't selected, so be careful. 7 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelNotExistsEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRLabelNotExistsEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(field: "skip", title: "Skip pull requests with missing label(s)?") { 8 | f.checkbox() 9 | } 10 | 11 | f.entry() { 12 | f.property(field: "label") 13 | } 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelNotExistsEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers or skips triggering when all the given labels are missing from a pull request. 3 |
4 | NOTE: This can cause infinite triggers of pull requests 5 | when the skip option isn't selected, so be careful. 6 |
7 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelPatternExistsEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRLabelPatternExistsEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(field: "skip", title: "Skip pull requests with label(s) matching pattern?") { 8 | f.checkbox() 9 | } 10 | 11 | f.entry() { 12 | f.property(field: "label") 13 | } 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelPatternExistsEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers when a label on a pull request matches the given pattern, or blocks 3 | triggering when a label matches, as configured. 4 |
5 | NOTE: This can cause infinite triggers of pull requests 6 | when the skip option isn't selected, so be careful. 7 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelRemovedEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRLabelRemovedEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry() { 8 | f.property(field: "label") 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRLabelRemovedEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers a build when the label or labels specified are removed from a 3 | pull request. Note that with multiple labels, all of the labels must be 4 | removed to cause the trigger to fire. 5 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRNonMergeableEvent/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRNonMergeableEvent 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(field: "skip", title: "Skip building unmergable pull requests?") { 8 | f.checkbox() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRNumber/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.events.impl.GitHubPRNumber 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(field: "number", title: "PR Number") { 8 | f.number() 9 | } 10 | 11 | f.entry(field: "match", title: "Match number?") { 12 | f.checkbox() 13 | } 14 | 15 | f.entry(field: "skip", title: "Skip when matching?") { 16 | f.checkbox() 17 | } 18 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRNumber/help-match.html: -------------------------------------------------------------------------------- 1 | Defines whether the pull request number in the trigger event must match to the above PR number. 2 | If not, then logic is not applied and the event wouldn't influence on the trigger result. 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRNumber/help-number.html: -------------------------------------------------------------------------------- 1 | PR number to run additional checks against 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPRNumber/help-skip.html: -------------------------------------------------------------------------------- 1 | Defines whether a matching or non matching pull request number in the trigger event, depending on the above "Match number" flag, skips building instead of triggering a build. 2 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/events/impl/GitHubPROpenEvent/help.html: -------------------------------------------------------------------------------- 1 |
2 | Triggers a build of a pull request when the pull request is opened or reopened. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/extra/GitHubPRLabelUnblockQueueCondition/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.extra.GitHubPRLabelUnblockQueueCondition 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.property(field: "label") 8 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/pipeline/SetCommitStatusStep/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.pipeline.SetCommitStatusStep 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | 8 | f.entry(title: _("Status context"), field: "context") { 9 | f.textbox() 10 | } 11 | 12 | f.entry(title: _("Status"), field: "state") { 13 | f.enum() { 14 | text(my.name().toLowerCase().capitalize()) 15 | } 16 | } 17 | 18 | f.entry(title: _("Status message"), field: "message") { 19 | f.textarea() 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/pipeline/SetCommitStatusStep/help-context.html: -------------------------------------------------------------------------------- 1 |
2 | A string label to differentiate this status from the status of other systems. 3 |
4 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/pipeline/SetCommitStatusStep/help-message.html: -------------------------------------------------------------------------------- 1 |
2 | A short detail message to add to the status 3 |
4 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/pipeline/SetCommitStatusStep/help-state.html: -------------------------------------------------------------------------------- 1 |
2 | State of the status indicating the progress or completion of the check. 3 |
4 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/pipeline/SetCommitStatusStep/help.html: -------------------------------------------------------------------------------- 1 |
2 | Sets the commit status of the commit that triggered a pull request build. Note that this 3 | step can only be used by builds that were triggered by a pull request. 4 |
5 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRBuildStatusPublisher/BuildMessage/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRBuildStatusPublisher.BuildMessage 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Build success message")) { 8 | f.property(field: "successMsg") 9 | } 10 | 11 | f.entry(title: _("Build failure message")) { 12 | f.property(field: "failureMsg") 13 | } 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRBuildStatusPublisher/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRBuildStatusPublisher; 2 | 3 | import org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRBuildStatusPublisher 4 | 5 | def f = namespace(lib.FormTagLib); 6 | 7 | // Stapler doesn't produce default values, so recreate object 8 | if (instance == null) { 9 | instance = new GitHubPRBuildStatusPublisher(); 10 | } 11 | 12 | f.optionalProperty(title: "Use only for builds with specific status", field: "statusVerifier") 13 | 14 | f.entry(title: _("Status message")) { 15 | f.property(field: "statusMsg") 16 | } 17 | 18 | f.entry(title: _("Mark unstable build in GitHub as "), field: "unstableAs") { 19 | f.enum() { 20 | text(my.name()) 21 | } 22 | } 23 | 24 | f.optionalProperty(title: "Use messages in case of status setting failure", field: "buildMessage") 25 | 26 | f.optionalProperty(title: "Handle publisher errors", field: "errorHandler") 27 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRBuildStatusPublisher/help-statusMsg.html: -------------------------------------------------------------------------------- 1 |
2 | Description message for GitHub status. 3 |
-------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRClosePublisher/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRClosePublisher 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.optionalProperty(title: "Use only for builds with specific status", field: "statusVerifier") 8 | 9 | f.optionalProperty(title: "Handle publisher errors", field: "errorHandler") 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRCommentPublisher/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRCommentPublisher 2 | 3 | import lib.FormTagLib; 4 | import org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRCommentPublisher; 5 | 6 | def f = namespace(FormTagLib); 7 | 8 | // Stapler doesn't produce default values, so recreate object 9 | if (instance == null) { 10 | instance = new GitHubPRCommentPublisher(); 11 | } 12 | 13 | f.optionalProperty(title: "Use only for builds with specific status", field: "statusVerifier") 14 | 15 | //f.entry(title:_("Comment content"), field:"comment"){ 16 | f.property(field: "comment") 17 | //} 18 | 19 | f.optionalProperty(title: "Handle publisher errors", field: "errorHandler") 20 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRLabelAddPublisher/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRLabelAddPublisher 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.optionalProperty(title: "Use only for builds with specific status", field: "statusVerifier") 8 | 9 | f.entry(title: _("Labels to add")) { 10 | f.property(field: "labelProperty") 11 | } 12 | 13 | f.optionalProperty(title: "Handle publisher errors", field: "errorHandler") 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/publishers/impl/GitHubPRLabelRemovePublisher/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRLabelRemovePublisher 2 | 3 | import lib.FormTagLib 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.optionalProperty(title: "Use only for builds with specific status", field: "statusVerifier") 8 | 9 | //f.entry(title:_("Labels to remove")) { 10 | f.property(field: "labelProperty") 11 | //} 12 | 13 | f.optionalProperty(title: "Handle publisher errors", field: "errorHandler") 14 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/restrictions/GitHubPRBranchRestriction/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.restrictions.GitHubPRBranchRestriction 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Whitelist Target Branches:"), field: "targetBranch") { 8 | f.expandableTextbox() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/restrictions/GitHubPRUserRestriction/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.restrictions.GitHubPRUserRestriction 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Organizations"), field: "orgs") { 8 | f.textarea() 9 | } 10 | 11 | f.entry(title: _("Users"), field: "users") { 12 | f.textarea() 13 | } 14 | 15 | //f.entry(title: _("Whitelist user msg"), field: "whitelistUserMsg") { 16 | // f.textbox(default: ".*add\\W+to\\W+whitelist.*") 17 | //} 18 | 19 | //f.entry(title: _("Organisations members as admins"), 20 | // field: "allowMembersOfWhitelistedOrgsAsAdmin") { 21 | // f.checkbox() 22 | //} 23 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/utils/PublisherErrorHandler/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.utils.PublisherErrorHandler 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("If publisher failed mark build as "), field: "buildStatus") { 8 | f.select() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/resources/org/jenkinsci/plugins/github/pullrequest/utils/StatusVerifier/config.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.utils.StatusVerifier 2 | 3 | import lib.FormTagLib; 4 | 5 | def f = namespace(FormTagLib); 6 | 7 | f.entry(title: _("Run when build status is better or equal"), field: "buildStatus") { 8 | f.select() 9 | } 10 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/webapp/git-tag.svg: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/main/webapp/scripts/featureButton.js: -------------------------------------------------------------------------------- 1 | function callFeature(button, answerPlaceId, parameters) { 2 | fetch(button.action, { 3 | method: "post", 4 | headers: crumb.wrap({ 5 | "Content-Type": "application/x-www-form-urlencoded", 6 | }), 7 | body: new URLSearchParams(parameters), 8 | }).then(rsp => { 9 | rsp.text().then((responseText) => { 10 | answerPlaceId.innerHTML = responseText; 11 | }); 12 | }); 13 | return false; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/com/github/kostyasha/github/integration/branch/its/GitHubBranchTriggerITest.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.its; 2 | 3 | import hudson.model.FreeStyleProject; 4 | import hudson.tasks.Shell; 5 | import org.junit.Ignore; 6 | import org.junit.Test; 7 | 8 | import static org.jenkinsci.plugins.github_integration.junit.GHRule.getDefaultBranchTrigger; 9 | import static org.jenkinsci.plugins.github_integration.junit.GHRule.getPreconfiguredProperty; 10 | 11 | /** 12 | * @author Kanstantsin Shautsou 13 | */ 14 | @Ignore 15 | public class GitHubBranchTriggerITest extends BranchITest { 16 | @Test 17 | public void freestyleTest() throws Exception { 18 | // create job 19 | FreeStyleProject job = jRule.createFreeStyleProject("freestyle-job"); 20 | 21 | job.addProperty(getPreconfiguredProperty(ghRule.getGhRepo())); 22 | 23 | job.addTrigger(getDefaultBranchTrigger()); 24 | 25 | job.getBuildersList().add(new Shell("env && sleep 2")); 26 | 27 | job.save(); 28 | 29 | super.smokeTest(job); 30 | } 31 | } -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/com/github/kostyasha/github/integration/branch/test/InjectJenkinsMembersRule.java: -------------------------------------------------------------------------------- 1 | package com.github.kostyasha.github.integration.branch.test; 2 | 3 | import org.junit.rules.ExternalResource; 4 | import org.jvnet.hudson.test.JenkinsRule; 5 | 6 | /** 7 | * Helpful class to make possible usage of 8 | * {@code @Inject 9 | * public GitHubPluginConfig config; 10 | * } 11 | *

12 | * in test fields instead of static calls {@link org.jenkinsci.plugins.github.GitHubPlugin#configuration()} 13 | *

14 | * See {@link com.cloudbees.jenkins.GitHubSetCommitStatusBuilderTest} for example 15 | * Should be used after JenkinsRule initialized 16 | *

17 | * {@code public RuleChain chain = RuleChain.outerRule(jRule).around(new InjectJenkinsMembersRule(jRule, this)); } 18 | * 19 | * @author lanwen (Merkushev Kirill) 20 | */ 21 | public class InjectJenkinsMembersRule extends ExternalResource { 22 | 23 | private JenkinsRule jRule; 24 | private Object instance; 25 | 26 | /** 27 | * @param jRule Jenkins rule 28 | * @param instance test class instance 29 | */ 30 | public InjectJenkinsMembersRule(JenkinsRule jRule, Object instance) { 31 | this.jRule = jRule; 32 | this.instance = instance; 33 | } 34 | 35 | @Override 36 | protected void before() throws Throwable { 37 | jRule.getInstance().getInjector().injectMembers(instance); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github/pullrequest/data/GitHubPREnvTest.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.data; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.hamcrest.Matchers.startsWith; 6 | import static org.junit.Assert.assertThat; 7 | 8 | /** 9 | * @author lanwen (Merkushev Kirill) 10 | */ 11 | public class GitHubPREnvTest { 12 | 13 | @Test 14 | public void shouldAddPrefixToStringVars() throws Exception { 15 | assertThat(GitHubPREnv.values()[0].param("value").getName(), startsWith(GitHubPREnv.PREFIX)); 16 | } 17 | 18 | @Test 19 | public void shouldAddPrefixToBoolVars() throws Exception { 20 | assertThat(GitHubPREnv.values()[0].param(true).getName(), startsWith(GitHubPREnv.PREFIX)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github/pullrequest/trigger/check/SkipFirstRunForPRFilterTest.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger.check; 2 | 3 | import org.jenkinsci.plugins.github.pullrequest.util.TaskListenerWrapperRule; 4 | import org.junit.Rule; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.kohsuke.github.GHPullRequest; 8 | import org.mockito.junit.MockitoJUnitRunner; 9 | 10 | import static org.hamcrest.MatcherAssert.assertThat; 11 | import static org.hamcrest.Matchers.is; 12 | import static org.jenkinsci.plugins.github.pullrequest.trigger.check.SkipFirstRunForPRFilter.ifSkippedFirstRun; 13 | 14 | /** 15 | * @author lanwen (Merkushev Kirill) 16 | */ 17 | @RunWith(MockitoJUnitRunner.class) 18 | public class SkipFirstRunForPRFilterTest { 19 | 20 | @Rule 21 | public TaskListenerWrapperRule tlRule = new TaskListenerWrapperRule(); 22 | 23 | @Test 24 | public void shouldSkipIfFR() throws Exception { 25 | assertThat("skip", ifSkippedFirstRun(tlRule.getListener(), true).apply(new GHPullRequest()), is(false)); 26 | } 27 | 28 | @Test 29 | public void shouldNotSkipIfNotSkipFR() throws Exception { 30 | assertThat("not skip", ifSkippedFirstRun(tlRule.getListener(), false).apply(new GHPullRequest()), is(true)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github/pullrequest/trigger/check/SkippedCauseFilterTest.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.trigger.check; 2 | 3 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRCause; 4 | import org.jenkinsci.plugins.github.pullrequest.util.TaskListenerWrapperRule; 5 | import org.junit.Rule; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.mockito.Mock; 9 | import org.mockito.junit.MockitoJUnitRunner; 10 | 11 | import static org.hamcrest.MatcherAssert.assertThat; 12 | import static org.hamcrest.Matchers.is; 13 | import static org.mockito.Mockito.when; 14 | 15 | /** 16 | * @author lanwen (Merkushev Kirill) 17 | */ 18 | @RunWith(MockitoJUnitRunner.class) 19 | public class SkippedCauseFilterTest { 20 | 21 | @Mock 22 | private GitHubPRCause cause; 23 | 24 | @Rule 25 | public TaskListenerWrapperRule tlRule = new TaskListenerWrapperRule(); 26 | 27 | @Test 28 | public void shouldSkip() throws Exception { 29 | when(cause.isSkip()).thenReturn(true); 30 | assertThat("skip", new SkippedCauseFilter(tlRule.getListener()).apply(cause), is(false)); 31 | } 32 | 33 | @Test 34 | public void shouldNotSkip() throws Exception { 35 | when(cause.isSkip()).thenReturn(false); 36 | assertThat("not skip", new SkippedCauseFilter(tlRule.getListener()).apply(cause), is(true)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github/pullrequest/util/TaskListenerWrapperRule.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.util; 2 | 3 | import org.jenkinsci.plugins.github.pullrequest.utils.LoggingTaskListenerWrapper; 4 | import org.junit.rules.TemporaryFolder; 5 | 6 | import static com.google.common.base.Charsets.UTF_8; 7 | 8 | /** 9 | * Rule with provides task listener with logging to file and to logger 10 | * 11 | * @author lanwen (Merkushev Kirill) 12 | */ 13 | public class TaskListenerWrapperRule extends TemporaryFolder { 14 | LoggingTaskListenerWrapper listener; 15 | 16 | @Override 17 | protected void before() throws Throwable { 18 | super.before(); 19 | listener = new LoggingTaskListenerWrapper(newFile(), UTF_8); 20 | } 21 | 22 | public LoggingTaskListenerWrapper getListener() { 23 | return listener; 24 | } 25 | } -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github/pullrequest/util/TestUtil.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github.pullrequest.util; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import org.apache.commons.io.IOUtils; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.lang.reflect.Field; 9 | 10 | import static java.lang.String.format; 11 | import static org.apache.commons.lang3.ClassUtils.PACKAGE_SEPARATOR; 12 | 13 | public final class TestUtil { 14 | private TestUtil() { 15 | } 16 | 17 | public static Field getPrivateField(String fieldName, Class clazz) throws NoSuchFieldException { 18 | Field field = clazz.getDeclaredField(fieldName); 19 | if (!field.isAccessible()) { 20 | field.setAccessible(true); 21 | } 22 | return field; 23 | } 24 | 25 | public static String classpath(Class clazz, String path) { 26 | try { 27 | return IOUtils.toString(clazz.getClassLoader().getResourceAsStream( 28 | clazz.getName().replace(PACKAGE_SEPARATOR, File.separator) + File.separator + path 29 | ), StandardCharsets.UTF_8); 30 | } catch (IOException e) { 31 | throw new RuntimeException(format("Can't load %s for class %s", path, clazz), e); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/awaitility/GHBranchAppeared.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.awaitility; 2 | 3 | import org.kohsuke.github.GHBranch; 4 | import org.kohsuke.github.GHRepository; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.util.Map; 9 | import java.util.concurrent.Callable; 10 | 11 | import static java.lang.System.currentTimeMillis; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | public class GHBranchAppeared implements Callable { 17 | private static final Logger LOG = LoggerFactory.getLogger(GHPRAppeared.class); 18 | 19 | private final String branchName; 20 | private final GHRepository repository; 21 | private final long startTime; 22 | 23 | public GHBranchAppeared(final GHRepository repository, String branchName) { 24 | this.branchName = branchName; 25 | this.repository = repository; 26 | startTime = currentTimeMillis(); 27 | } 28 | 29 | @Override 30 | public Boolean call() throws Exception { 31 | for (Map.Entry entry : repository.getBranches().entrySet()) { 32 | if (entry.getKey().equals(branchName)) { 33 | LOG.debug("[WAIT] appeared branch {}, delay {} ms", branchName, currentTimeMillis() - startTime); 34 | return true; 35 | } 36 | } 37 | LOG.debug("[WAIT] no Branch {}", branchName); 38 | return false; 39 | } 40 | 41 | public static GHBranchAppeared ghBranchAppeared(GHRepository repository, String branchName) { 42 | return new GHBranchAppeared(repository, branchName); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/awaitility/GHFromServerConfigAppeared.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.awaitility; 2 | 3 | import org.jenkinsci.plugins.github.config.GitHubServerConfig; 4 | import org.kohsuke.github.GitHub; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.util.concurrent.Callable; 9 | 10 | import static java.lang.System.currentTimeMillis; 11 | import static org.jenkinsci.plugins.github.config.GitHubServerConfig.loginToGithub; 12 | import static java.util.Objects.nonNull; 13 | 14 | /** 15 | * @author Kanstantsin Shautsou 16 | */ 17 | public class GHFromServerConfigAppeared implements Callable { 18 | private static final Logger LOG = LoggerFactory.getLogger(GHFromServerConfigAppeared.class); 19 | private GitHubServerConfig gitHubServerConfig; 20 | final long timeBefore; 21 | 22 | public GHFromServerConfigAppeared(GitHubServerConfig gitHubServerConfig) { 23 | this.gitHubServerConfig = gitHubServerConfig; 24 | timeBefore = currentTimeMillis(); 25 | } 26 | 27 | @Override 28 | public Boolean call() throws Exception { 29 | GitHub gitHub = loginToGithub().apply(gitHubServerConfig); 30 | if (nonNull(gitHub)) { 31 | LOG.debug("loginToGithub() delay {} ms.", currentTimeMillis() - timeBefore); 32 | return true; 33 | } 34 | 35 | throw new AssertionError("GitHub doesn't appear"); 36 | } 37 | 38 | public static Callable ghAppeared(GitHubServerConfig gitHubServerConfig) { 39 | return new GHFromServerConfigAppeared(gitHubServerConfig); 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/awaitility/GHPRAppeared.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.awaitility; 2 | 3 | import org.kohsuke.github.GHIssueState; 4 | import org.kohsuke.github.GHPullRequest; 5 | import org.kohsuke.github.GHRepository; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.util.concurrent.Callable; 10 | 11 | import static java.lang.System.currentTimeMillis; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | public class GHPRAppeared implements Callable { 17 | private static final Logger LOG = LoggerFactory.getLogger(GHPRAppeared.class); 18 | 19 | private final GHPullRequest pullRequest; 20 | private final GHRepository repository; 21 | private final long startTime; 22 | 23 | public GHPRAppeared(final GHPullRequest pullRequest) { 24 | this.pullRequest = pullRequest; 25 | repository = pullRequest.getRepository(); 26 | startTime = currentTimeMillis(); 27 | } 28 | 29 | @Override 30 | public Boolean call() throws Exception { 31 | for (GHPullRequest pr : repository.listPullRequests(GHIssueState.OPEN)) { 32 | if (pr.getNumber() == pullRequest.getNumber()) { 33 | LOG.debug("[WAIT] appeared PR {}, delay {} ms", pullRequest.getNumber(), currentTimeMillis() - startTime); 34 | return true; 35 | } 36 | } 37 | LOG.debug("[WAIT] no PR {}", pullRequest.getNumber()); 38 | return false; 39 | } 40 | 41 | public static GHPRAppeared ghPRAppeared(GHPullRequest pullRequest) { 42 | return new GHPRAppeared(pullRequest); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/awaitility/GHRepoAppeared.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.awaitility; 2 | 3 | import org.kohsuke.github.GHRepository; 4 | import org.kohsuke.github.GitHub; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.io.FileNotFoundException; 9 | import java.util.concurrent.Callable; 10 | 11 | import static java.util.Objects.isNull; 12 | import static java.util.Objects.nonNull; 13 | 14 | /** 15 | * @author Kanstantsin Shautsou 16 | */ 17 | public class GHRepoAppeared implements Callable { 18 | private static final Logger LOG = LoggerFactory.getLogger(GHRepoAppeared.class); 19 | 20 | private final GitHub gitHub; 21 | private final String repoName; 22 | 23 | public GHRepoAppeared(final GitHub gitHub, final String repoName) { 24 | this.gitHub = gitHub; 25 | this.repoName = repoName; 26 | } 27 | 28 | @Override 29 | public Boolean call() throws Exception { 30 | GHRepository repository = null; 31 | try { 32 | repository = gitHub.getRepository(repoName); 33 | } catch (FileNotFoundException ignore) { 34 | } 35 | LOG.debug("[WAIT] GitHub repository '{}' {}", repoName, isNull(repository) ? "doesn't appeared" : "appeared"); 36 | return nonNull(repository); 37 | } 38 | 39 | public static Callable ghRepoAppeared(final GitHub gitHub, final String repoName) { 40 | return new GHRepoAppeared(gitHub, repoName); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/awaitility/GHRepoDeleted.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.awaitility; 2 | 3 | import org.kohsuke.github.GHRepository; 4 | import org.kohsuke.github.GitHub; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import java.io.FileNotFoundException; 9 | import java.util.concurrent.Callable; 10 | 11 | import static java.util.Objects.isNull; 12 | 13 | /** 14 | * @author Kanstantsin Shautsou 15 | */ 16 | public class GHRepoDeleted implements Callable { 17 | private static final Logger LOG = LoggerFactory.getLogger(GHRepoDeleted.class); 18 | 19 | private GitHub gitHub; 20 | private String repoName; 21 | 22 | public GHRepoDeleted(final GitHub gitHub, final String repoName) { 23 | this.gitHub = gitHub; 24 | this.repoName = repoName; 25 | } 26 | 27 | @Override 28 | public Boolean call() throws Exception { 29 | GHRepository repository; 30 | try { 31 | repository = gitHub.getRepository(repoName); 32 | } catch (FileNotFoundException ignore) { 33 | LOG.debug("[WAIT] GitHub repository '{}' doesn't found", repoName); 34 | return true; 35 | } 36 | 37 | LOG.debug("[WAIT] GitHub repository '{}' {}", repoName, isNull(repository) ? "doesn't found" : "exists"); 38 | return isNull(repository); 39 | } 40 | 41 | public static Callable ghRepoDeleted(final GitHub gitHub, final String repoName) { 42 | return new GHRepoDeleted(gitHub, repoName); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/hamcrest/CommitStatusMatcher.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.hamcrest; 2 | 3 | //import org.hamcrest.Factory; 4 | import org.hamcrest.FeatureMatcher; 5 | import org.hamcrest.Matcher; 6 | import org.kohsuke.github.GHCommitState; 7 | import org.kohsuke.github.GHCommitStatus; 8 | 9 | import static org.hamcrest.core.Is.is; 10 | 11 | /** 12 | * @author Kanstantsin Shautsou 13 | */ 14 | public class CommitStatusMatcher extends FeatureMatcher { 15 | private String context; 16 | private GHCommitState state; 17 | private String description; 18 | 19 | public CommitStatusMatcher(Matcher subMatcher, 20 | String context, 21 | GHCommitState state, 22 | String description) { 23 | super(subMatcher, "", ""); 24 | this.context = context; 25 | this.state = state; 26 | this.description = description; 27 | } 28 | 29 | @Override 30 | protected Boolean featureValueOf(GHCommitStatus commitStatus) { 31 | return commitStatus.getState().equals(state) && 32 | commitStatus.getContext().equals(context) && 33 | commitStatus.getDescription().equals(description); 34 | } 35 | 36 | //@Factory 37 | public static CommitStatusMatcher commitStatus(String context, 38 | GHCommitState state, 39 | String description) { 40 | return new CommitStatusMatcher(is(true), context, state, description); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/its/FreestyleITest.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.its; 2 | 3 | import hudson.model.FreeStyleProject; 4 | import hudson.tasks.Shell; 5 | import org.jenkinsci.plugins.github.pullrequest.GitHubPRMessage; 6 | import org.jenkinsci.plugins.github.pullrequest.builders.GitHubPRStatusBuilder; 7 | import org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRBuildStatusPublisher; 8 | import org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRCommentPublisher; 9 | import org.junit.Ignore; 10 | import org.junit.Test; 11 | 12 | import static org.jenkinsci.plugins.github_integration.junit.GHRule.getPreconfiguredProperty; 13 | import static org.jenkinsci.plugins.github_integration.junit.GHRule.getPreconfiguredPRTrigger; 14 | 15 | /** 16 | * @author Kanstantsin Shautsou 17 | */ 18 | @Ignore 19 | public class FreestyleITest extends AbstractPRTest { 20 | 21 | @Test 22 | public void freestyleTest() throws Exception { 23 | // create job 24 | FreeStyleProject job = jRule.createFreeStyleProject("freestyle-job"); 25 | 26 | job.addProperty(getPreconfiguredProperty(ghRule.getGhRepo())); 27 | 28 | job.addTrigger(getPreconfiguredPRTrigger()); 29 | 30 | job.getBuildersList().add(new GitHubPRStatusBuilder()); 31 | job.getBuildersList().add(new Shell("sleep 10")); 32 | 33 | job.getPublishersList().add(new GitHubPRBuildStatusPublisher()); 34 | job.getPublishersList().add(new GitHubPRCommentPublisher(new GitHubPRMessage("Comment"), null, null)); 35 | 36 | job.save(); 37 | 38 | super.basicTest(job); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/java/org/jenkinsci/plugins/github_integration/its/WorkflowFailTest.java: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.its; 2 | 3 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; 4 | import org.junit.Ignore; 5 | import org.junit.Rule; 6 | import org.junit.Test; 7 | import org.jvnet.hudson.test.JenkinsRule; 8 | import org.jvnet.hudson.test.recipes.WithTimeout; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | /** 13 | * @author Kanstantsin Shautsou 14 | */ 15 | @Ignore(value = "Test class") 16 | public class WorkflowFailTest { 17 | 18 | private static final Logger LOG = LoggerFactory.getLogger(WorkflowFailTest.class); 19 | 20 | @Rule 21 | public JenkinsRule j = new JenkinsRule(); 22 | 23 | @WithTimeout(value = 0) 24 | @Test 25 | public void testWFHSError() throws Exception { 26 | final WorkflowJob workflow = j.getInstance().createProject(WorkflowJob.class, "workflow"); 27 | workflow.save(); 28 | LOG.info(workflow.getAbsoluteUrl()); 29 | j.configRoundtrip(workflow); // fails 30 | // j.pause(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/checkstyle/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/actualiseRepo/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/actualiseRepo/jobs/project/com.github.kostyasha.github.integration.branch.GitHubBranchRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | KostyaSha-auto/test 4 | https://github.com/KostyaSha-auto/test/ 5 | git://github.com/KostyaSha-auto/test.git 6 | git@github.com:KostyaSha-auto/test.git 7 | 8 | 9 | old-repo 10 | 11 | old-repo 12 | 6dcb09b5b57875f334f61aebed695e2e4193fffb 13 | https://github.com/KostyaSha-auto/test/tree/old-repo 14 | 15 | 16 | 17 | old-branch 18 | 19 | old-branch 20 | 6dcb09b5b57875f334f61aebed695e2e4193ffbe 21 | https://github.com/KostyaSha-auto/test/tree/old-branch 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/actualiseRepo/jobs/project/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | 5 | 6 | https://github.com/KostyaSha-auto/test/ 7 | 8 | 9 | 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | CRON 18 | false 19 | false 20 | false 21 | 22 | 23 | 24 | 25 | false 26 | 27 | 28 | false 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/buildButtonsPerms/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/buildButtonsPerms/jobs/project/com.github.kostyasha.github.integration.branch.GitHubBranchRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | for-removal 6 | 7 | for-removal 8 | 6dcb09b5b57875f334f61aebed695e2e4193fffe 9 | http://localhost/org/repo/tree/for-removal 10 | 11 | 12 | 13 | should-change 14 | 15 | should-change 16 | 6dcb09b5b57875f334f61aebed695e2e4193ffbb 17 | http://localhost/org/repo/tree/should-change 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/buildButtonsPerms/jobs/project/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | 5 | 6 | http://localhost/org/repo/ 7 | 8 | 9 | 10 | false 11 | false 12 | false 13 | false 14 | 15 | 16 | 17 | CRON 18 | false 19 | false 20 | false 21 | 22 | 23 | 24 | 25 | false 26 | 27 | 28 | false 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/someTest/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/GitHubBranchTriggerTest/someTest/jobs/project/com.github.kostyasha.github.integration.branch.GitHubBranchRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org/repo 4 | http://localhost/org/repo 5 | git://localhost/org/repo.git 6 | git@localhost:org/repo.git 7 | 8 | 9 | for-removal 10 | 11 | for-removal 12 | 6dcb09b5b57875f334f61aebed695e2e4193fffe 13 | http://localhost/org/repo/tree/for-removal 14 | 15 | 16 | 17 | should-change 18 | 19 | should-change 20 | 6dcb09b5b57875f334f61aebed695e2e4193ffbb 21 | http://localhost/org/repo/tree/should-change 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/test/GHMockRule/branch-should-change.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "should-change", 3 | "commit": { 4 | "sha": "6dcb09b5b57875f334f61aebed695e2e4193ffgg", 5 | "commit": { 6 | "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193ffgg", 7 | "message": "Merge pull request #6 from Spaceghost/patch-1\n\nNew line at end of file." 8 | }, 9 | "url": "https://api.github.com/repos/octocat/Hello-World/commits/7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", 10 | "committer": { 11 | "gravatar_id": "", 12 | "avatar_url": "https://secure.gravatar.com/avatar/7ad39074b0584bc555d0417ae3e7d974?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", 13 | "url": "https://api.github.com/users/octocat", 14 | "id": 583231, 15 | "login": "octocat" 16 | } 17 | }, 18 | "protected": true, 19 | "protection_url": "https://api.github.com/repos/octocat/Hello-World/branches/should-change/protection" 20 | } 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/test/GHMockRule/org-repo-branches.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "new-branch", 4 | "commit": { 5 | "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", 6 | "url": "https://api.github.com/repos/octocat/Hello-World/commits/c5b97d5ae6c19d5c5df71a34c7fbeeda2479ccbc" 7 | }, 8 | "protected": true, 9 | "protection_url": "https://api.github.com/repos/octocat/Hello-World/branches/new-branch/protection" 10 | }, 11 | { 12 | "name": "should-change", 13 | "commit": { 14 | "sha": "6dcb09b5b57875f334f61aebed695e2e4193ffgg", 15 | "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193ffgg" 16 | }, 17 | "protected": true, 18 | "protection_url": "https://api.github.com/repos/octocat/Hello-World/branches/should-change/protection" 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/com/github/kostyasha/github/integration/branch/test/GHMockRule/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "login": "login", 3 | "id": 2341, 4 | "avatar_url": "", 5 | "gravatar_id": "", 6 | "url": "https://api.github.com/users/login", 7 | "html_url": "https://github.com/login", 8 | "followers_url": "https://api.github.com/users/login/followers", 9 | "following_url": "https://api.github.com/users/login/following{/other_user}", 10 | "gists_url": "https://api.github.com/users/login/gists{/gist_id}", 11 | "starred_url": "https://api.github.com/users/login/starred{/owner}{/repo}", 12 | "subscriptions_url": "https://api.github.com/users/login/subscriptions", 13 | "organizations_url": "https://api.github.com/users/login/orgs", 14 | "repos_url": "https://api.github.com/users/login/repos", 15 | "events_url": "https://api.github.com/users/login/events{/privacy}", 16 | "received_events_url": "https://api.github.com/users/login/received_events", 17 | "type": "User", 18 | "site_admin": false, 19 | "name": "User", 20 | "company": "Company", 21 | "blog": "http://blog.blog", 22 | "location": "Location", 23 | "email": null, 24 | "hireable": null, 25 | "bio": null, 26 | "public_repos": 1, 27 | "public_gists": 1, 28 | "followers": 1, 29 | "following": 1, 30 | "created_at": "2012-07-12T16:12:59Z", 31 | "updated_at": "2015-10-05T08:55:34Z", 32 | "private_gists": 1, 33 | "total_private_repos": 0, 34 | "owned_private_repos": 0, 35 | "disk_usage": 10, 36 | "collaborators": 0, 37 | "plan": { 38 | "name": "free", 39 | "space": 976562499, 40 | "collaborators": 0, 41 | "private_repos": 0 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/dsl/branch-jobdsl.groovy: -------------------------------------------------------------------------------- 1 | freeStyleJob('gh-branch') { 2 | 3 | triggers { 4 | onBranch { 5 | setPreStatus() 6 | cancelQueued() 7 | 8 | mode { 9 | cron() 10 | heavyHooks() 11 | heavyHooksCron() 12 | } 13 | 14 | repoProviders { 15 | gitHubPlugin { 16 | manageHooks(false) 17 | cacheConnection(false) 18 | permission { pull() } 19 | } 20 | } 21 | 22 | events { 23 | 24 | branchRestriction { 25 | matchCritieria('master') 26 | matchCritieria('other') 27 | } 28 | 29 | commitChecks { 30 | commitMessagePattern { 31 | excludeMatching() 32 | matchCritieria('^(?s)\\[(release|unleash)\\-maven\\-plugin\\].*') 33 | } 34 | } 35 | 36 | created() 37 | hashChanged() 38 | deleted() 39 | } 40 | 41 | whitelistedBranches('master') 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/invalidConfig/org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/logback.groovy_: -------------------------------------------------------------------------------- 1 | import ch.qos.logback.classic.encoder.PatternLayoutEncoder 2 | import ch.qos.logback.core.ConsoleAppender 3 | 4 | import static ch.qos.logback.classic.Level.DEBUG 5 | import static ch.qos.logback.classic.Level.INFO 6 | 7 | appender("STDOUT", ConsoleAppender) { 8 | encoder(PatternLayoutEncoder) { 9 | pattern = "%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n" 10 | } 11 | } 12 | 13 | logger("org.jenkinsci.plugins.github", DEBUG) 14 | logger("org.jenkinsci.plugins.github_integration", DEBUG) 15 | 16 | root(INFO, ["STDOUT"]) 17 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMockTest/actualiseRepo/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMockTest/actualiseRepo/jobs/project/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | https://localhost/org/old-repo/ 9 | display-name 10 | 11 | 12 | 13 | true 14 | false 15 | false 16 | false 17 | 18 | 19 | 20 | HEAVY_HOOKS 21 | 22 | 23 | 24 | 25 | false 26 | false 27 | false 28 | 29 | 30 | false 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMockTest/actualiseRepo/jobs/project/org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org/old-repo 4 | https://localhost/org/old-repo/ 5 | git://localhost/org/old-repo.git 6 | git@localhost:org/old-repo.git 7 | 8 | 9 | 1 10 | 11 | 1 12 | 2016-04-18 06:53:41.0 UTC 13 | Update README.md 14 | 2016-04-18 06:53:41.0 UTC 15 | 65d0f7818009811e5d5eb703ebad38bbcc816b49 16 | KostyaSha-auto-patch-1 17 | true 18 | master 19 | KostyaSha-auto 20 | https://localhost/org/old-repo/pull/1 21 | 2016-04-18 06:53:41.0 UTC 22 | KostyaSha-auto 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMockTest/badStatePR/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMockTest/badStatePR/jobs/test-job/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | https://localhost/org/repo/ 9 | display-name 10 | 11 | 12 | 13 | true 14 | false 15 | false 16 | false 17 | 18 | 19 | 20 | HEAVY_HOOKS 21 | 22 | 23 | 24 | 25 | false 26 | false 27 | false 28 | 29 | 30 | false 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerMockTest/badStatePR/jobs/test-job/org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org/repo 4 | https://localhost/org/repo/ 5 | git://localhost/org/repo.git 6 | git@localhost:org/repo.git 7 | 8 | 9 | 1 10 | 11 | 1 12 | 2016-04-18 06:53:41.0 UTC 13 | Update README.md 14 | 2016-04-18 06:53:41.0 UTC 15 | 65d0f7818009811e5d5eb703ebad38bbcc816b49 16 | KostyaSha-auto-patch-1 17 | true 18 | master 19 | KostyaSha-auto 20 | https://localhost/org/repo/pull/1 21 | 2016-04-18 06:53:41.0 UTC 22 | KostyaSha-auto 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerTest/buildButtonsPerms/jobs/project/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | 7 | 8 | https://localhost.localdomain/KostyaSha-auto/test/ 9 | display-name 10 | 11 | 12 | 13 | true 14 | false 15 | false 16 | false 17 | 18 | 19 | 20 | CRON 21 | 22 | 23 | 24 | 25 | false 26 | false 27 | false 28 | 29 | 30 | false 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerTest/buildButtonsPerms/jobs/project/org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | KostyaSha-auto/test 4 | https://github.com/KostyaSha-auto/test/ 5 | git://github.com/KostyaSha-auto/test.git 6 | git@github.com:KostyaSha-auto/test.git 7 | 8 | 9 | 1 10 | 11 | 1 12 | 2016-04-18 06:53:41.0 UTC 13 | Update README.md 14 | 2016-04-18 06:53:41.0 UTC 15 | 65d0f7818009811e5d5eb703ebad38bbcc816b49 16 | KostyaSha-auto-patch-1 17 | true 18 | master 19 | KostyaSha-auto 20 | https://github.com/KostyaSha-auto/test/pull/1 21 | 22 | 2016-04-18 06:53:41.0 UTC 23 | KostyaSha-auto 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github/pullrequest/GitHubPRTriggerTest/ensureOldValid/jobs/test-job/org.jenkinsci.plugins.github.pullrequest.GitHubPRRepository.runtime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | KostyaSha-auto/test 4 | https://github.com/KostyaSha-auto/test/ 5 | git://github.com/KostyaSha-auto/test.git 6 | git@github.com:KostyaSha-auto/test.git 7 | 8 | 9 | 1 10 | 11 | 1 12 | 2016-04-18 06:53:41.0 UTC 13 | Update README.md 14 | 2016-04-18 06:53:41.0 UTC 15 | 65d0f7818009811e5d5eb703ebad38bbcc816b49 16 | KostyaSha-auto-patch-1 17 | true 18 | master 19 | KostyaSha-auto 20 | https://github.com/KostyaSha-auto/test/pull/1 21 | 22 | 2016-04-18 06:53:41.0 UTC 23 | KostyaSha-auto 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github_integration/its/WorkflowITest/testContextStatuses.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.its.WorkflowITest 2 | 3 | 4 | try { 5 | setGitHubPullRequestStatus state: 'PENDING', context: 'custom-context1', message: "Run #${env.BUILD_NUMBER} started" 6 | setGitHubPullRequestStatus state: 'PENDING', context: 'custom-context2', message: "Run #${env.BUILD_NUMBER} started" 7 | 8 | node('master') { 9 | step([ 10 | $class : 'GitHubPRStatusBuilder', 11 | statusMessage: [ 12 | content: "Run #${env.BUILD_NUMBER} started" 13 | ] 14 | ]) 15 | 16 | sh 'sleep 10 && env' 17 | 18 | setGitHubPullRequestStatus state: 'SUCCESS', context: 'custom-context1', message: 'Tests passed' 19 | setGitHubPullRequestStatus state: 'SUCCESS', context: 'custom-context2', message: 'Tests passed' 20 | step([ 21 | $class : 'GitHubPRBuildStatusPublisher', 22 | statusMsg : [ 23 | content: 'Run #${BUILD_NUMBER} ended normally' 24 | ], 25 | unstableAs: 'FAILURE' 26 | ]) 27 | } 28 | } catch (Exception e) { 29 | setGitHubPullRequestStatus state: 'FAILURE', context: 'custom-context1', message: 'Some tests failed' 30 | setGitHubPullRequestStatus state: 'FAILURE', context: 'custom-context2', message: 'Some tests failed' 31 | throw e 32 | } 33 | -------------------------------------------------------------------------------- /github-pullrequest-plugin/src/test/resources/org/jenkinsci/plugins/github_integration/its/WorkflowITest/workflowTest.groovy: -------------------------------------------------------------------------------- 1 | package org.jenkinsci.plugins.github_integration.its.WorkflowITest 2 | 3 | node('master') { 4 | step([ 5 | $class : 'GitHubPRStatusBuilder', 6 | statusMessage: [ 7 | content: "Build #${env.BUILD_NUMBER} started" 8 | ] 9 | ]) 10 | // 11 | // checkout([ 12 | // $class: 'GitSCM', 13 | // branches: [[name: "origin-pull/pull/${GITHUB_PR_NUMBER}/merge"]], 14 | // doGenerateSubmoduleConfigurations: false, 15 | // extensions: [], 16 | // submoduleCfg: [], 17 | // userRemoteConfigs: [ 18 | // [ 19 | // credentialsId: 'df5e384b-e836-42a0-b5cc-445e88ac6700', 20 | // name: 'origin-pull', 21 | // refspec: "+refs/pull/${GITHUB_PR_NUMBER}/merge:refs/remotes/origin-pull/pull/${GITHUB_PR_NUMBER}/merge", 22 | // url: 'git://github.com/KostyaSha/test-repo.git' 23 | // ] 24 | // ] 25 | // ]) 26 | 27 | sh 'sleep 10 && env' 28 | step([ 29 | $class : 'GitHubPRBuildStatusPublisher', 30 | statusMsg : [ 31 | content: 'Build #${BUILD_NUMBER} ended' 32 | ], 33 | unstableAs: 'FAILURE' 34 | ]) 35 | } 36 | -------------------------------------------------------------------------------- /travis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | #sudo apt-get update && sudo apt-get install oracle-java8-installer 7 | java -version 8 | 9 | ./mvnw -v 10 | ./mvnw -Dignore.random.failures=true clean verify -Ptravis | grep -v Download 11 | --------------------------------------------------------------------------------