stashnotifier-plugin icon indicating copy to clipboard operation
stashnotifier-plugin copied to clipboard

Job continues to run on password expiration exception

Open Constantin07 opened this issue 4 years ago • 2 comments
trafficstars

Version report

Jenkins and plugins versions report:

Jenkins 2.277.1
stashNotifier 1.20
  • What Operating System are you using (both controller, and any agents involved in the problem)?
Linux Alpine 3.12.0

Reproduction steps

  • Have the password expired for credentials used to authenticate to Bitbucket Server
  • Send a notification in pipeline:
pipeline {
...
  stages {
    stage('Test') {
      ...
      mlaNotifyBitbucket 'SUCCESSFUL'
    }
  }
...
}

Results

Expected result:

The job should fail if cannot successfully send notification to Bitbucket Server

Actual result:

It continues to run with next stage as there no error happened at all:

[Pipeline] notifyBitbucket
Notifying Bitbucket at "https://some-bitbucket-server-here"
Failed to notify Bitbucket for commit b3e025790f8e28cc87334dfb341c1f085c1da6f6 ({"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.ExpiredPasswordAuthenticationException"}]})
[Pipeline] }
[Pipeline] // stage
...

Constantin07 avatar May 12 '21 17:05 Constantin07

Build notification is not a mandatory step in my mind to abort the whole build when notification fails. If you want to catch errors from notifiers - I hope you can wrap it into try..catch clause and do an error step there.

scaytrase avatar May 12 '21 18:05 scaytrase

@scaytrase wrapping in try catch doesn't work. It just continues to run the pipeline.

    try {
        notifyBitbucket(
            stashServerBaseUrl: 'https://*******',
            ....
        )
    } catch (Exception e) {
        echo 'Exception occured: ' + e.toString()
        error("Bitbucket notification failed.")
    }
[Pipeline] notifyBitbucket
Notifying Bitbucket at "https://******"
Failed to notify Bitbucket for commit 0255fe7ba98c0e3103c89341b626d7a64e6b941 ({"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]})
[Pipeline] }
[Pipeline] // stage

I'm using it in multibranch pipeline to notify Bitbucket that Build was successful (or not) so the it can be merged only when someone had reviewed PR and the build was OK.

It does make sense to know somehow when notification to Bitbucket fails or doesn't work (I can use Slack notifications for this if pipeline fails) but at the moment I don't know how this can be done if it just continues even with error.

Constantin07 avatar Aug 13 '21 09:08 Constantin07