Giter VIP home page Giter VIP logo

stashnotifier-plugin's Introduction

Bitbucket Server Notifier Plugin for Jenkins

This Jenkins plugin notifies Bitbucket Server (formerly known as Stash) of build results. Failed or successful builds will show up as little icons in Bitbucket's web interface in commit logs. Clicking on such an icon will take the user to the specific build.

Requirements

This plugin uses the Atlassian Stash / Bitbucket Server Build REST API.

Setup

Set up Bitbucket Server Notifier by navigating to Manage Jenkins --> Configure System and scrolling down to the Bitbucket Server Notifier section. Enter at least your Server base URL and Credentials. Additional options are available as required.

Bitbucket Server Notifier Settings

Script setup

Either automatically upon Jenkins post-initialization or through Jenkins Script Console, example:

Jenkins
    .instance
    .getDescriptor('org.jenkinsci.plugins.stashNotifier.StashNotifier')
    .with{
        credentialsId = 'bitbucket-creds'
        stashRootUrl = 'https://my.company.intranet/bitbucket'
        ignoreUnverifiedSsl = true
        disableInprogressNotification = true
        includeBuildNumberInKey = false
        prependParentProjectKey = false
        considerUnstableAsSuccess = false
    }

Usage

Use the Bitbucket Server Notifier by adding it as a Post Step in your Jenkins build job configuration.

  1. In your Jenkins job configuration go to the Post-build Actions section, click on Add post-build action and select Notify Bitbucket Instance.
  2. Enter the Server base URL, e. g. http://localhost:7990 or https://my.company.intranet/bitbucket.
    If in doubt, go to your local Bitbucket server and check the URL in the browser. The URL http://georg@localhost:7991/projects e. g. reveals the server base URL, which is http://localhost:7991 in this case.
  3. Select the Credentials for authenticating with Bitbucket.
    Please note that SSH credentials (public/private key) from Jenkins that might be added to Bitbucket are not used for the authentication. Typically, in order to access Bitbucket you would add a service account (username and password) to Jenkins.

That's it. If you have configured everything correctly, Jenkins will notify your Bitbucket instance of subsequent builds. The result is illustrated on the Atlassian Bitbucket Build Integration wiki page.

Note on Pipeline Plugin usage

See the following code for an example of how to use this plugin inside of a Pipeline. You must set the result of the current build manually in the Pipeline script.

node {
    checkout scm                            // Necessary so we know the current commit

    notifyBitbucket()                       // Notifies the Bitbucket instance of an INPROGRESS build

    try {
        // Do stuff

        currentBuild.result = 'SUCCESS'     // Set result of currentBuild !Important!
    } catch(err) {
        currentBuild.result = 'FAILURE'     // Set result of currentBuild !Important!
    }

    notifyBitbucket()                       // Notifies the Bitbucket instance of the build result
}

Or you could as well use

    checkout scm
    
    notifyBitbucket(buildStatus: 'INPROGRESS')        // Notifies the Bitbucket instance of an INPROGRESS build
    
    try {
        // Do stuff
        notifyBitbucket(buildStatus: 'SUCCESSFUL')    // Notifies the Bitbucket instance of an SUCCESSFUL build
    } catch(err) {
        // Do clean up
        notifyBitbucket(buildStatus: 'FAILED')        // Notifies the Bitbucket instance of an FAILED build
    }

In situations where an advanced setup is required the following can be used:

node {
    this.notifyBitbucket('INPROGRESS')     // Notifies the Bitbucket instance of an INPROGRESS build

    try {
        // Do stuff

        this.notifyBitbucket('SUCCESS')
    } catch(err) {
        this.notifyBitbucket('FAILED')
    }
}

def notifyBitbucket(String state) {
    notifyBitbucket(
            commitSha1: 'commit',
            credentialsId: '00000000-1111-2222-3333-123456789abc',
            disableInprogressNotification: false,
            considerUnstableAsSuccess: true,
            ignoreUnverifiedSSLPeer: true,
            buildStatus: state,
            buildName: 'Performance Testing',
            buildUrl: 'https://my.company.intranet/bitbucket/custom-build-url',
            includeBuildNumberInKey: false,
            prependParentProjectKey: false,
            projectKey: '',
            stashServerBaseUrl: 'https://my.company.intranet/bitbucket')

}

In Declarative Pipelines, where Jenkins sets currentBuild.result = null for SUCCESS builds, the current value can be modified via a script step, e.g.:

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                echo 'Hello World'
                // currentBuild.result == null here
            }
        }
    }
    post {
        always {
            script {
                currentBuild.result = currentBuild.result ?: 'SUCCESS'
                notifyBitbucket()
            }
        }
    }
}

Note on credentials

Currently Bitbucket Server Build Notifier accepts only raw plaintext credentials as it uses the HTTP REST API of Bitbucket.

Maintainers

License

Apache 2.0 License

stashnotifier-plugin's People

Contributors

aaronjwood avatar barney2k7 avatar cyburs avatar darxriggs avatar dependabot[bot] avatar gruetter avatar jakub-bochenski avatar jetersen avatar jinnthegeek avatar johnjohndoe avatar lakritzator avatar lucamilanesio avatar mdkf avatar notmyfault avatar noxo avatar offa avatar penland365 avatar pongells avatar proski avatar reftel avatar robinverduijn avatar scaytrase avatar sdmoralesma avatar sghill avatar sghill-rewrite avatar tandrup avatar thomaseizinger avatar vassilevsky avatar westarne avatar wilfred avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stashnotifier-plugin's Issues

Please provide per Jenkins-Project Key setting

I would like to get the ability the change the KEY-json field which is sent to the Stash server on a per project basis. Basically i want to be able to set the same Key for several Jenkins projects which map to the same Stash repoitory.
The Key should default to the Project name, but be editable.

Issue with SSL certificate

Hi,

The plugin cannot be made to accept my valid SSL certificate, due to a change in behavior between versions of Apache Httpclient (4.1 works, 4.1.1 doesn't). Httpclient as used by this plugin considers the certificate of another vhost of the webserver rather than the one associated with my servername.

Please have a look at https://issues.apache.org/jira/browse/HTTPCLIENT-1578 and https://github.com/rcomblen/HttpClientRegressionTest for more details.

Apache Httpclient developer suggest to use an alternative implementation, which is not available with version 4.2.5 of the Httpclient currently shipped with Jenkins.

For now, the solution I've taken is to change the classloader behavior for the plugin, following https://wiki.jenkins-ci.org/display/JENKINS/Plugin+Structure

The leads to the following patch:

commit 8622a0064516a10db4bacc6537c23777dda2d419
Author: Richard Comblen <[email protected]>
Date:   Wed Nov 12 08:51:03 2014 +0100

    Force version of HTTPCLIENT

diff --git a/pom.xml b/pom.xml
index c75ebf7..d0bfdcc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,4 +68,15 @@
            <url>http://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>
+<build>
+  <plugins>
+    <plugin>
+      <groupId>org.jenkins-ci.tools</groupId>
+      <artifactId>maven-hpi-plugin</artifactId>
+      <configuration>
+        <pluginFirstClassLoader>true</pluginFirstClassLoader>
+      </configuration>
+    </plugin>
+  </plugins>
+</build>
 </project>

I'm not sure an action should be taken on your side before Jenkins ships with a newer version of Httpclient, still I want this to be documented, so I open this issue.

Pull Request Notifications

Hi, I'm trying to configure jenkins jobs that build pull requests and provide feedback on the stash pull request page but so far am unable to get the notification displayed.

The job builds with the refspec +refs/pull-requests//merge:refs/remotes/origin/pr/ and is correctly triggered and if i navigate directly to the pull request commit I can see the job success however this is not included in the builds on the pull request itself.

Is the above possible? am I missing something?

Many thanks

Tom

Use credential plugin

I'd like this plugins to use the credentials plugin, because, for instance, I'm being required to provide a client certificate and your plugin doesn't have a way to do that.

After a failed build, re-running the build does not update Stash status to green

According to Stash documentation,
https://developer.atlassian.com/stash/docs/latest/how-tos/updating-build-status-for-commits.html

On the section "False alarm", I have exactly the same situation, a broken build due to infrastucture. I then re-run the build (no further commits), and the build status on Stash does not update to "green". Even though the build list shows Stash has been notified. (ie, I have 2 failed builds and 1 green build), but it shows as "failed build".

I also have "keep repeated builds in stash" selected.

I'm using Stash 2.5, with stashnotifier 1.5.

Thanks
Jonny

Remove build number from KEY

When experiencing issues with Jenkins job configuration, which causes the build to fail, subsequent re-runs of the build mark it as passed, however, because the KEY sent to Stash contains the build number, this is no longer treated by Stash as an override, but rather a unique build.

NullPointerException if no Stash user password is specified

I get a NullPointerException if I leave the Stash user password field blank in the post-build action.

Caught exception while notifying Stash with id f213d5f5d67ac56580b2071d0e1088788f5897c2
java.lang.NullPointerException
at org.jenkinsci.plugins.stashNotifier.StashNotifier.createRequest(StashNotifier.java:591)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.notifyStash(StashNotifier.java:553)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:207)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:174)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1053)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1766)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:537)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:408)

Note that if I fill it the build hangs for several minutes. Stash notifiers end up by failing with a java.net.SocketException: "Connection reset".

I am using Jenkins v1.627, StashNotifier v1.8 and Stash v3.10.

Build with no revision to build causes NullPointerException

Hi,
If I have a build configured with currently no active branch causes the StashNotifier plugin to throw a NullPointerException:
Seen branch in repository origin/master
Seen 1 remote branch
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Sending e-mails to: *************
ERROR: Build step failed with exception
java.lang.NullPointerException
at org.jenkinsci.plugins.stashNotifier.StashNotifier.lookupCommitSha1s(StashNotifier.java:263)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:204)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:171)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
at hudson.model.Run.execute(Run.java:1766)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Build step 'Notify Stash Instance' marked build as failure
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

Checking Ignore unverified SSL certificates does not actually ignore

Even though I have 'Ignore unverified SLL certificates' I still get the message:
'SSLPeerUnverifiedException caught while notifying Stash. Make sure your SSL certificate on your Stash server is valid or check the 'Ignore unverifiable SSL certificate' checkbox in the Stash plugin configuration of this job.' in my console output.

Debug Logs for Rest API Calls?

Is there anything available on the Jenkins side for viewing what REST API calls are being generated and sent to Stash? I'm trying to troubleshoot a weird issue and it would be helpful to see what the JSON being sent looks like. I haven't been able to find anything in the logs.

Please add a setting to disable Stash notification _before_ building

Right before start of a building, the plugin is sending a notification to Stash that build is building. If a build is interrupted especially by a groovy script (for example, while terminating duplicate builds started by notifications) the following Stash notification is not sending, so Stash will keep this notification as "Building" forever.

Moreover, the plug-in description does not contains any mention about pre-build actions that can not be avoided or disabled.

notification fails when Stash Root Url ends with "/"

on jenkins v 1.602 and v 1.8 of the plugin when my URL ends in "/" the notification fails with the message "Failed to notify Stash for commit [HASH]" followed by an unhelpful HTML splat. If I remove the final "/" the notification succeeds.

I see the plugin is handling the obvious case of just checking for the presence of a final "/" and normalizing the string, so I'm not sure what could be causing the problem.

Support for multiple SCM's

If I have a job with multiple SCM's the notifier only publishes the results to the first listed repository.

Ideally I'd like to be able to choose which repositories to publish results to.

Multiple builds of same commit show as one build on the stash page

One commit in git that is build multiple times (same job) yields only 1 result in Stash.
This is due to the 'key' in the JSON being posted to stash not being unique (maybe append build-number?)

Sometimes we have to restart a failed job because of external components that fails the integration test (if the job is an integration test job), or because the code analysis is returning false positives and marks the build as failed.

Cannot notify Stash! (Jenkins Root URL not configured)

I get the message Cannot notify Stash! (Jenkins Root URL not configured) with the following versions:
Jenkins: 1.625.2
StashNotifier: 1.9.0

No clue, where this comes from, because the following script executes just fine on my instance's script console:

Jenkins.instance.getRootUrl()

Result: https://jenkins/

Any ideas?

NullPointerException in StashNotifier.lookupCommitSha1s

Plugin version: 1.8
Jenkins version: 1.627
Stash version: 3.11.2

ERROR: Build step failed with exception
java.lang.NullPointerException
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.lookupCommitSha1s(StashNotifier.java:263)
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:204)
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:171)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
    at hudson.model.Build$BuildExecution.post2(Build.java:185)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
    at hudson.model.Run.execute(Run.java:1766)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:408)
Build step 'Notify Stash Instance' marked build as failure

Pre-notify before build starts

I'd like to have know if this plugin could send notifications for job runs that are queued, but not yet running.

The problem I'm seeing is that we have a limited number of Jenkins executors. Users create 15 PRs in stash. Each PR triggers a notification to Jenkins. Jenkins queues up all of these jobs. However, it does not trigger the stash rest api that a job has started -- thus the PR at stash looks like no build job has been triggered. The stash side doesn't see the "build in progress" till the job is finally picked up.

Ideally the stash notifier could "ping back" to Stash once the job is queued, not once it's begun.

Is that possible?

Retroactive Build Status Updates

Not something broken with the plugin, but it would be nice to have the ability to run the Stash Notifier on previous builds that were run before installation of the plugin.

False negative build failure for last successful SHA is sent to Stash upon clone failure

Background

We're using Stash and have a "minimum successful build" requirement on Pull Requests. We also have a build set up in Jenkins as our "authoritative build" upon which we base our acceptance of the pull request.

This build has a parameterized repository URL, and everyone is able to use it, point it to point to their own forks and build their branches.

Problem is, sometimes people open up a pull request, get a successful build, only to find later that their build has been marked unsuccessful due to this bug.

Scenario & Reproduction Steps

  • Sue makes commit with SHA 'abc123' on her fork to branch "sues-branch"
  • Sue kicks off the build and gets a successful build
  • This is correctly reported to Stash as a success against 'abc123'
  • Jim makes commit with SHA 'def456' onto his fork to branch "jims-branch"
  • Jim then attempts to kick off the build, but forgets to change the repository URL to his fork (it has some other default)
  • Build fails because branch 'jims-branch' did not exist on the main repository

Expected result:

  • No notification sent to stash

Actual result:

  • Notification is sent to stash with sue's commit SHA of 'abc123' (i.e. last successful build). This marks Sue's pull request as failing (i.e. a false negative).

Version details

Jenkins version: 1.509.4
Stash notifier plugin version: 1.5

FATAL: No author in changeset

Sometimes when pushing a build to Stash Jenkins builds sucessfully then fails on the notification stage with this error

Notified Stash for commit with id 82876141c3a1c294d7d965fb953077ddb22c9390
FATAL: No author in changeset 6babe4a858ac6b361920a44b6ad1
java.lang.RuntimeException: No author in changeset 6babe4a858ac6b361920a44b6ad1
at hudson.plugins.git.GitChangeSet.getAuthor(GitChangeSet.java:324)
at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:352)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:667)
at hudson.model.Run.execute(Run.java:1714)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)

Looking at the git history for this specific example the 6babe4a858ac6b361920a44b6ad1 commit was merged onto master before this branch was built and does contain an Author as far as git extensions is concerned.

"Ignore unverified SSL certificates" does not reflect actual config value

While the configuration file contains

<ignoreUnverifiedSsl>true</ignoreUnverifiedSsl>

the interface for the Stash Notifier does not check (enable) the checkbox next to "Ignore unverified SSL certificates".

This has the undesirable effect that each time I save a changed configuration, this feature is disabled unintentionally. To avoid this effect, I have to check that option manually which is quite error-prone.

Notify Stash even when SCM is not GIT

It is kind of a corner case, but I actually need this.

I have a pipeline Unit Tests -> Integration -> System. UT job gets code from GIT, runs unit tests, notifies Stash and archives the workspace. IT and all further jobs use the workspace created by UT job. They do what they suppose to do and try to notify Stash, but fail with "found no commit info". So in any pipeline only the first job submits results to Stash.

Due to certain inner issues, I can't use GIT in all the steps of the pipeline.

So it would be nice to have an option to inject GIT info from a file to stashnotifier-plugin, if you want to report build results of a job which does not have GIT SCM configured.

Right now my solution to the problem is to use Groovy script to report to Stash. But it is really messy. Really looking for a cleaner solution. Please let me know what you think.

Password Is Exposed

When I load an existing job for configuration via the "Configure" link, and open the Stash Notifier configuration section, an existing password value is populated, albeit hidden. However, the true value of the password is available, and Firefox was able to see it and show it to me.

Is this a breakdown in the abstract plugin config architecture that's not hiding this properly, or a concrete option that stashnotifier is not setting to tell the abstract parent "this is a password (or otherwise encrypted) value, so don't expose it"?

Or, is there a presumption that anyone with access to configure a build job is allowed access to that password value?

FATAL: NoClassDefFound - stashNotifier/UnsafeX509TrustManager

Scenario

  • Jenkins 1.509.1 LTS running inside Tomcat
  • Running StashNotifier 1.4 against an unstrusted SSL protected Stash instance
  • Upgraded to 1.5 and restarted Jenkins (But not Tomcat)

Problem

On completion of a build, the notification event throws the following exception in logs, causing the build to show as RED Failed.

Trying with safe trust manager, instead!
FATAL: org/jenkinsci/plugins/stashNotifier/UnsafeX509TrustManager
java.lang.NoClassDefFoundError: org/jenkinsci/plugins/stashNotifier/UnsafeX509TrustManager
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.getHttpClient(StashNotifier.java:205)
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:149)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:802)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:774)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:949)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:724)
    at hudson.model.Run.execute(Run.java:1600)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.ClassNotFoundException: org.jenkinsci.plugins.stashNotifier.UnsafeX509TrustManager
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 11 more

Workaround

  • Rolled back to 1.4 and builds stablised

Option to postpone in-progress notification to after injection of environment variables

We may have a special setup but maybe this suggestion makes sense for others as well.

For us, the notification for a new build being in progress happens too early, before the commit hash is available (provided to stashnotifier-plugin using the commitSha1 parameter). As you can see in the example build output below, the notifer runs before we have injected environment variables (including the necessary commit hash in $revision from version.properties).

We have quite a lot of code which is why we have chosen to have a job that checks out code. Other jobs can then copy (some) artifacts from that job and do their thing. That way, we only check out code once but it means that other jobs needs to have some properties injected.

We have not found a way to postpone the notification to after injection of environment variables, hence this feature request.

Started by upstream project "Checkout" build number 53
originally caused by:
 Started by an SCM change
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
[EnvInject] - Injecting as environment variables the properties content 
GIT_REPO=<removed>
BRANCH_NAME=master
SB_REVISION=$SB_REVISION
SB_DESCRIPTION=$SB_DESCRIPTION
SB_URL=$SB_URL

[EnvInject] - Variables injected successfully.
[EnvInject] - Injecting contributions.
Building on master in workspace /jenkins/conf/jobs/Compile/workspace
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Failed to notify Stash for commit $revision ({"errors":[{"context":null,"message":"Please specify the changeset id as a 40-character hash","exceptionName":null}]})
Copied 36,061 artifacts from "Checkout" build number 53
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'folders_sha.properties'
[EnvInject] - Variables injected successfully.
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'version.properties'
[EnvInject] - Variables injected successfully.
(...)

handshake alert: unrecognized_name exception

I ticked the "Ignore unverified SSL certificates" configuration option, but this plugin is still throwing the following exception:

Caught exception while notifying Stash with id eca2af599d0d511e184b9037f4c7f0f5568c6eea
javax.net.ssl.SSLProtocolException: handshake alert:  unrecognized_name
    at sun.security.ssl.ClientHandshaker.handshakeAlert(ClientHandshaker.java:1380)
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1972)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:395)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:354)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
    at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:338)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.notifyStash(StashNotifier.java:556)
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:207)
    at org.jenkinsci.plugins.stashNotifier.StashNotifier.prebuild(StashNotifier.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:834)
    at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:829)
    at hudson.model.Build$BuildExecution.doRun(Build.java:144)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1744)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)

ignoreUnverifiedSSLPeer not working

im trying to integrate jenkins with a stash instance that uses https with a self-signed certificate.

i have <ignoreUnverifiedSSLPeer>true</ignoreUnverifiedSSLPeer> both in global settings (~jenkins/org.jenkinsci.plugins.stashNotifier.StashNotifier.xml) and in the job configuration (~jenkins/jobs/job-name/config.xml) and yet in the job output console i get this:

Caught exception while notifying Stash with id [hash]
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIXpath building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:533)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:401)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.notifyStash(StashNotifier.java:546)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:207)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.perform(StashNotifier.java:174)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:772)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:736)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1040)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:685)
at hudson.model.Run.execute(Run.java:1757)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
... 29 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 35 more

Stash notifies when using the conditional build step

I'm using the conditional build step with Stash Notify. If the conditional build step prevents the Stash notification then in Stash I get "build in progress" indefinitely.
Regardless of the conditional build step Stash gets notified at the beginning of a build that it's in progress.

Maybe have the plugin not do the initial notification if conditional build step is being used? Or have an option to not use the initial notification all together?

Ability to pass additional message and the end of a build

In some cases it would be useful to pass additional text to be displayed in Stash at the end of a build - e.g. warnings or test failed tests. It would be great to have an ability to for example write a Groovy code to do any custom logic and returns text to be passed to Stash.

The simplified version of that feature could be reading a defined text file (which could be created by for example external build step written in Groovy).

Concurrent builds cause subsequent builds to hang waiting for the first one to finish

We are trying to get concurrent builds going in Jenkins for the job that is using this plugin to notify Stash of build results. However, I am frequently observing that if one build is hanging due to some reason (say, a bad test), the subsequent builds which are executing concurrently, and are now "finished", hang at this line in the console output until the first build is done or times out:

Notify Stash Instance is waiting for a checkpoint on stash-gater-turn #295

So it would seem that something in the plugin does not support concurrent builds? This is a blocker for us.

Global configuration not working

When I configure stash notifier locally for a dedicted job the notification is working as expected.
However the global configuration seems not to work.

When I configure stash notifier globally do I also have to configure notifier on the job itself?
Independent if it is configured on the job or not it is not working.
If I configure it on the job without adding anything to the details section I get an authentication error. If I fill the data it is working. If I remove the notifier from the job itself nothing is happening in respect to stash notification.

Autocomplete shouldn't populate stash notifier config?

We put the userid and password for stash notifier in the global config. Therefore there is no userid or password in the job configuration. However, if you edit any Jenkins job, in certain situations, a userid and password will automatically be inserted in the job config.

Steps to reproduce:

  1. Use either Chrome or Firefox (didn't test IE), and have the browser save your password on the Jenkins 'login' page
  2. Edit any job that has stash notifier and save. You can edit anything - it doesn't have to be related to stash notifier.
  3. Look at the config.xml and see your userid and password in the stash notifier section.

Since the userid and password are hidden under an 'Advanced' button, if you don't have it expanded, you won't even notice this has happened when configuring the page.

One obvious fix is to not have your browser store your credentials, but how do you keep all users from doing that?

Would this work?
http://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag

use a proxy for communication with stash

Hi,

the plugin doesn't seem to use a proxy for communication with stash. We get a "connection refused" error, though we already set the proxy configuration correctly both in jenkins and java.

Allow to enter the commit hash as a parameter

Now only projects that use GIT versioning can use this plugin. But when you chain multiple projects together you don't want to check out the project each time(time consuming, disk space, and most of all consistency; if a developer pushes changes when the chain of jobs is executing you don't want to have that change pop-up in the middle)

Would it be possible to add a textbox allowing us to enter the commit hash (which could very well be a parameter passed down from a previous job). If it is not entered, you can still retrieve it the old way (assume that this project uses git versioning)

This would be a most helpful improvement to this addon for us!

Allow safer authentication mechanisms to stash

I'd love to use this functionality, but currently you have to store your username/password in plaintext in the jenkins settings.

Are there other possibilities to let Jenkins notify Stash without storing credentials on a shared Jenkins server?

The Stash documentation mentions:

The REST APIs support basic authentication, OAuth and session authentication.

Maybe OAuth is an option?

Unable to Notify Stash After Build

I'm unable to get the stash notification plugin to work. I have the 'Ignore unverifiable SSL certificate' checkbox checked on my project, but I still get this error message in the logs:

SSLPeerUnverifiedException caught while notifying Stash. Make sure your SSL certificate on your Stash server is valid or check the 'Ignore unverifiable SSL certificate' checkbox in the Stash plugin configuration of this job.

UnsupportedSchemeException: http protocol is not supported while notifying Stash

I am getting this exception with v1.8 of the Stash Notifier plugin. But it impacts some jobs and not others, currently unable to work out what is different about the jobs to cause this problem.
The Repository URL is http://stash-my-server:port/scm/repo/my-project.git
The Repository browser is set to stash, with an equivalent URL: http://stash-my-server:port/projects/repo/repos/my-project/browse
The Notify Stash Instance section has got the Stash base URL set to blank; but this works for other jobs using the same jenkins server and stash instance.

Caught exception while notifying Stash with id {HASH}
org.apache.http.conn.UnsupportedSchemeException: http protocol is not supported
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:108)
at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:338)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:388)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.notifyStash(StashNotifier.java:556)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.processJenkinsEvent(StashNotifier.java:207)
at org.jenkinsci.plugins.stashNotifier.StashNotifier.prebuild(StashNotifier.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:816)
at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:811)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:664)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
at hudson.model.Run.execute(Run.java:1751)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)

Build status

Hi,
Let's say the i'm pushing a few commits, and build is failing, as i can see the hook is displaying the build status next to the last commit that was made by me.
Is it ok ?
Is there anyway to improve it, we can get all the commits that were made by the same push, and display this notification next to them.
Another thing which i'm not sure that it's possible to implement, is there any way that we can track down the commit that cause the build to fail?

Failed to notify Stash for commit 5c458cc3866a7ebacceec1f28770899c6b637a81

When we downgrade to 1.7 because of the issue #57, we are getting following error:

Failed to notify Stash for commit 5c458cc3866a7ebacceec1f28770899c6b637a81 (<HEAD><TITLE>internal error - server connection terminated</TITLE></HEAD>
<BODY BGCOLOR="white" FGCOLOR="black"><H1>internal error - server connection terminated</H1><HR>
<FONT FACE="Helvetica,Arial"><B>
Description: internal error - server connection terminated</B></FONT>
<HR>
<!-- default "internal error - server connection terminated" response (502) -->
</BODY>
)

Stash Base URL http://git.mydomain.com:7990

Any idea why am I getting this error?

Follow redirects

Hello :)
Our systems administrators have enabled HTTPS for Stash.
So the Stash URL changed from http:// to https://.
After that the plugin started to output errors to build logs. Errors said that the web server returned 301 Moved Permanently.
We of course added the "s" letters to job configs. Everything is OK now.
I just report this issue in case you have lots of free time and want to add some kind of "follow redirects" option to the HTTP client you're using.
Thanks!

Failed to notify Stash for commit, ({"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":null}]})

Hi,

Stash v3.11.3
Jenkins 1.529
Stash Notifier plugin : tested with both 1.5 and 1.9.0.

This is the error, same thing with v1.5 and v1.9.0 of the Stash Notifier plugin:

Failed to notify Stash for commit xxxx ({"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":null}]}).

We are not specifying any value in these fields:

Ignore unverified SSL certificates,
Keep repeated builds in Stash
Override project key
Prepend parent project name to key
Disable INPROGRESS notification

It stopped working after upgrading our Stash server from v2.10.2 to v3.11.3. We tried upgrading the Stash Notifier plugin to the latest version and using the Credentials plugin to do the authenticate, but still getting the same issue.

Would you have any idea about why it does fail? May I'm missing something at config level. Any advise is welcome.

Thanks,
Angela.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.