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
public class StashNotifier extends Notifier implements 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 Classes Modifier and Type Class Description static class
StashNotifier.DescriptorImpl
-
Nested 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
Fields Modifier and Type Field Description static int
MAX_FIELD_LENGTH
static int
MAX_URL_FIELD_LENGTH
-
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
-
-
Constructor Summary
Constructors Constructor Description StashNotifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected 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.String
getBuildName()
protected String
getBuildName(Run<?,?> run)
Returns the build name to be pushed.StashBuildState
getBuildStatus()
String
getBuildUrl()
protected String
getBuildUrl(Run<?,?> run)
Returns the build url to be pushed.String
getCommitSha1()
String
getCredentialsId()
StashNotifier.DescriptorImpl
getDescriptor()
protected org.apache.http.impl.client.CloseableHttpClient
getHttpClient(PrintStream logger, Run<?,?> run, String stashServer)
Deprecated.String
getProjectKey()
protected StashBuildState
getPushedBuildStatus(StashBuildState currentBuildStatus)
Returns the build state to be pushed.BuildStepMonitor
getRequiredMonitorService()
String
getStashServerBaseUrl()
boolean
isConsiderUnstableAsSuccess()
boolean
isDisableInprogressNotification()
boolean
isIgnoreUnverifiedSSLPeer()
boolean
isIncludeBuildNumberInKey()
boolean
isPrependParentProjectKey()
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 Detail
-
MAX_FIELD_LENGTH
public static final int MAX_FIELD_LENGTH
- See Also:
- Constant Field Values
-
MAX_URL_FIELD_LENGTH
public static final int MAX_URL_FIELD_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRequiredMonitorService
public BuildStepMonitor getRequiredMonitorService()
- Specified by:
getRequiredMonitorService
in interfaceBuildStep
-
getStashServerBaseUrl
public String getStashServerBaseUrl()
-
setStashServerBaseUrl
@DataBoundSetter public void setStashServerBaseUrl(String stashServerBaseUrl)
-
getCredentialsId
public String getCredentialsId()
-
setCredentialsId
@DataBoundSetter public void setCredentialsId(String credentialsId)
-
isIgnoreUnverifiedSSLPeer
public boolean isIgnoreUnverifiedSSLPeer()
-
setIgnoreUnverifiedSSLPeer
@DataBoundSetter public void setIgnoreUnverifiedSSLPeer(boolean ignoreUnverifiedSSLPeer)
-
getCommitSha1
public String getCommitSha1()
-
setCommitSha1
@DataBoundSetter public void setCommitSha1(String commitSha1)
-
getBuildStatus
public StashBuildState getBuildStatus()
-
setBuildStatus
@DataBoundSetter public void setBuildStatus(Object buildStatus)
-
getBuildName
public String getBuildName()
-
setBuildName
@DataBoundSetter public void setBuildName(String buildName)
-
getBuildUrl
public String getBuildUrl()
-
setBuildUrl
@DataBoundSetter public void setBuildUrl(String buildUrl)
-
isIncludeBuildNumberInKey
public boolean isIncludeBuildNumberInKey()
-
setIncludeBuildNumberInKey
@DataBoundSetter public void setIncludeBuildNumberInKey(boolean includeBuildNumberInKey)
-
getProjectKey
public String getProjectKey()
-
setProjectKey
@DataBoundSetter public void setProjectKey(String projectKey)
-
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
public boolean prebuild(AbstractBuild<?,?> build, BuildListener listener)
- Specified by:
prebuild
in interfaceBuildStep
- Overrides:
prebuild
in classBuildStepCompatibilityLayer
-
perform
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener)
- 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
protected Collection<String> lookupCommitSha1s(Run run, FilePath workspace, TaskListener listener)
-
getHttpClient
@Deprecated protected org.apache.http.impl.client.CloseableHttpClient getHttpClient(PrintStream logger, Run<?,?> run, String stashServer) throws Exception
Deprecated.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
public StashNotifier.DescriptorImpl 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
protected StashBuildState getPushedBuildStatus(StashBuildState currentBuildStatus)
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
protected String getBuildKey(Run<?,?> run, TaskListener listener)
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
protected String getBuildName(Run<?,?> run)
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
protected String getBuildUrl(Run<?,?> run)
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
protected String getBuildDescription(Run<?,?> run, StashBuildState state)
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
-
-