Class StashNotifier
java.lang.Object
hudson.tasks.BuildStepCompatibilityLayer
hudson.tasks.Publisher
hudson.tasks.Notifier
org.jenkinsci.plugins.stashNotifier.StashNotifier
- All Implemented Interfaces:
ExtensionPoint
,Describable<Publisher>
,BuildStep
,SimpleBuildStep
Notifies a configured Atlassian Bitbucket server instance of build results
through the Bitbucket build API.
Only basic authentication is supported at the moment.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class hudson.tasks.Publisher
Publisher.DescriptorExtensionListImpl
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
BuildStep.PublisherList
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
Nested classes/interfaces inherited from interface jenkins.tasks.SimpleBuildStep
SimpleBuildStep.LastBuildAction, SimpleBuildStep.LastBuildActionFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.client.methods.HttpPost
createRequest
(org.apache.http.HttpEntity stashBuildNotificationEntity, Item project, String commitSha1, String url) Deprecated.in favor of method overloadprotected String
getBuildDescription
(Run<?, ?> run, StashBuildState state) Returns the description of the run used for the Bitbucket notification.protected String
getBuildKey
(Run<?, ?> run, TaskListener listener) Returns the run key used in the Bitbucket notification.protected String
getBuildName
(Run<?, ?> run) Returns the build name to be pushed.protected String
getBuildUrl
(Run<?, ?> run) Returns the build url to be pushed.protected org.apache.http.impl.client.CloseableHttpClient
getHttpClient
(PrintStream logger, Run<?, ?> run, String stashServer) Deprecated.protected StashBuildState
getPushedBuildStatus
(StashBuildState currentBuildStatus) Returns the build state to be pushed.boolean
boolean
boolean
boolean
boolean
protected Collection<String>
lookupCommitSha1s
(Run run, FilePath workspace, TaskListener listener) protected NotificationResult
notifyStash
(PrintStream logger, Run<?, ?> run, String commitSha1, TaskListener listener, StashBuildState state) Notifies the configured Bitbucket server by POSTing the run results to the Bitbucket run API.boolean
perform
(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) void
perform
(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) boolean
prebuild
(AbstractBuild<?, ?> build, BuildListener listener) void
setBuildName
(String buildName) void
setBuildStatus
(Object buildStatus) void
setBuildUrl
(String buildUrl) void
setCommitSha1
(String commitSha1) void
setConsiderUnstableAsSuccess
(boolean considerUnstableAsSuccess) void
setCredentialsId
(String credentialsId) void
setDisableInprogressNotification
(boolean disableInprogressNotification) void
setIgnoreUnverifiedSSLPeer
(boolean ignoreUnverifiedSSLPeer) void
setIncludeBuildNumberInKey
(boolean includeBuildNumberInKey) void
setPrependParentProjectKey
(boolean prependParentProjectKey) void
setProjectKey
(String projectKey) void
setStashServerBaseUrl
(String stashServerBaseUrl) Methods inherited from class hudson.tasks.Publisher
all, getProjectAction, needsToRunAfterFinalized, prebuild
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectActions, perform
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions
Methods inherited from interface jenkins.tasks.SimpleBuildStep
perform, perform, requiresWorkspace
-
Field Details
-
MAX_FIELD_LENGTH
public static final int MAX_FIELD_LENGTH- See Also:
-
MAX_URL_FIELD_LENGTH
public static final int MAX_URL_FIELD_LENGTH- See Also:
-
-
Constructor Details
-
StashNotifier
@DataBoundConstructor public StashNotifier()
-
-
Method Details
-
getRequiredMonitorService
- Specified by:
getRequiredMonitorService
in interfaceBuildStep
-
getStashServerBaseUrl
-
setStashServerBaseUrl
-
getCredentialsId
-
setCredentialsId
-
isIgnoreUnverifiedSSLPeer
public boolean isIgnoreUnverifiedSSLPeer() -
setIgnoreUnverifiedSSLPeer
@DataBoundSetter public void setIgnoreUnverifiedSSLPeer(boolean ignoreUnverifiedSSLPeer) -
getCommitSha1
-
setCommitSha1
-
getBuildStatus
-
setBuildStatus
-
getBuildName
-
setBuildName
-
getBuildUrl
-
setBuildUrl
-
isIncludeBuildNumberInKey
public boolean isIncludeBuildNumberInKey() -
setIncludeBuildNumberInKey
@DataBoundSetter public void setIncludeBuildNumberInKey(boolean includeBuildNumberInKey) -
getProjectKey
-
setProjectKey
-
isPrependParentProjectKey
public boolean isPrependParentProjectKey() -
setPrependParentProjectKey
@DataBoundSetter public void setPrependParentProjectKey(boolean prependParentProjectKey) -
isDisableInprogressNotification
public boolean isDisableInprogressNotification() -
setDisableInprogressNotification
@DataBoundSetter public void setDisableInprogressNotification(boolean disableInprogressNotification) -
isConsiderUnstableAsSuccess
public boolean isConsiderUnstableAsSuccess() -
setConsiderUnstableAsSuccess
@DataBoundSetter public void setConsiderUnstableAsSuccess(boolean considerUnstableAsSuccess) -
prebuild
- Specified by:
prebuild
in interfaceBuildStep
- Overrides:
prebuild
in classBuildStepCompatibilityLayer
-
perform
- Specified by:
perform
in interfaceBuildStep
- Overrides:
perform
in classBuildStepCompatibilityLayer
-
perform
public void perform(@NonNull Run<?, ?> run, @NonNull FilePath workspace, @NonNull Launcher launcher, @NonNull TaskListener listener) - Specified by:
perform
in interfaceSimpleBuildStep
-
lookupCommitSha1s
-
getHttpClient
@Deprecated protected org.apache.http.impl.client.CloseableHttpClient getHttpClient(PrintStream logger, Run<?, ?> run, String stashServer) throws ExceptionDeprecated.Returns the HttpClient through which the REST call is made. Uses an unsafe TrustStrategy in case the user specified a HTTPS URL and set the ignoreUnverifiedSSLPeer flag.- Throws:
Exception
- See Also:
-
DefaultApacheHttpNotifier.getHttpClient(PrintStream, URI, boolean)
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<Publisher>
- Overrides:
getDescriptor
in classNotifier
-
notifyStash
protected NotificationResult notifyStash(PrintStream logger, Run<?, ?> run, String commitSha1, TaskListener listener, StashBuildState state) Notifies the configured Bitbucket server by POSTing the run results to the Bitbucket run API.- Parameters:
logger
- the logger to userun
- the run to notify Bitbucket ofcommitSha1
- the SHA1 of the run commitlistener
- the run listener for loggingstate
- the state of the build as defined by the Bitbucket API.
-
getPushedBuildStatus
Returns the build state to be pushed. This will select the specifically overwritten build state or the current build state else.- Parameters:
currentBuildStatus
- the state of the current build- Returns:
- the current build status
-
createRequest
protected org.apache.http.client.methods.HttpPost createRequest(org.apache.http.HttpEntity stashBuildNotificationEntity, Item project, String commitSha1, String url) throws org.apache.http.auth.AuthenticationException Deprecated.in favor of method overloadReturns the HTTP POST request ready to be sent to the Bitbucket build API for the given run and change set.- Parameters:
stashBuildNotificationEntity
- a entity containing the parameters for BitbucketcommitSha1
- the SHA1 of the commit that was builturl
- Bitbucket URL- Returns:
- the HTTP POST request to the Bitbucket build API
- Throws:
org.apache.http.auth.AuthenticationException
- See Also:
-
DefaultApacheHttpNotifier.createRequest(URI, JSONObject, Credentials, NotificationContext)
-
getBuildKey
Returns the run key used in the Bitbucket notification. Includes the run number depending on the user setting.- Parameters:
run
- the run to notify Bitbucket of- Returns:
- the run key for the Bitbucket notification
-
getBuildName
Returns the build name to be pushed. This will select the specifically overwritten build name or get the build name from theRun
.- Parameters:
run
- the run to notify Bitbucket of- Returns:
- the name of the run
-
getBuildUrl
Returns the build url to be pushed. This will select the specifically overwritten build url or get the build url from theDisplayURLProvider
.- Parameters:
run
- the run to notify Bitbucket of- Returns:
- the url of the run
-
getBuildDescription
Returns the description of the run used for the Bitbucket notification. Uses the run description provided by the Jenkins job, if available.- Parameters:
run
- the run to be describedstate
- the state of the run- Returns:
- the description of the run
-