-
Bug
-
Resolution: Cannot Reproduce
-
Major
-
Jenkins 2.19.1(installed via apt)
master and nodes (via ssh): ubuntu 14.04.5 LTS, openJDK 1.8.0_91
bitbucket-build-status-notifier 1.3.1
pipeline: shared groovy libraries 2.5
pipeline remote loader 1.3
git plugin 3.0.1
My organization has been using Jenkins 2.0 and Pipelines for several months. We've reached a critical point where we need a global library to consolidate functionality and reduce configuration drift of our Jenkinsfiles and scripts. I created a git repo in our Bitbucket team to hold common functions, the first of which are notifications classes for sending build status to Hipchat and Bitbucket (e.g. src/com/team/notifications/Bitbucket.groovy):
+package com.team.jenkins.notifications + +class Bitbucket implements Serializable { + + def script + Bitbucket(script) { + this.script = script + } + + def started() { + this.script.bitbucketStatusNotify ( + buildState: 'INPROGRESS' + ) + } + + def succeeded() { + this.script.bitbucketStatusNotify ( + buildState: 'SUCCESSFUL' + ) + } + + def failed(stage, err) { + this.script.bitbucketStatusNotify ( + buildState: 'FAILED', + buildDescription: "Build failed during ${stage}: ${err}" + ) + } +}
Our development workflow depends on Jenkins build approvals of pull requests, using the Bitbucket build status notifier plugin. The above class "works", in that it sends build status notifications to bitbucket, but the problem is that it is always sending those notifications to the shared library repo, not the repo that is being built (e.g. one of our Java libraries or webapps).
I have tested the above library as both a class and as a global var implementation, both explicitly and implicitly loaded into the pipeline script. I have also confirmed that the normal non-shared-library usage of the bitbucket-status-notifier plugin is affected by the shared library git repo, so the plugin can't be used at all, it seems, if there's a shared library brought into a pipeline job. Here's its usage as an explicit library:
@Library('common-jenkins') import com.team.jenkins.notifications.Bitbucket def bitbucketer node() { stage('init) { git url: 'https://user@bitbucket.org/team/repo.git' bitbucketer = new Bitbucket(this) sh './gradlew clean' bitbucketer.started() } stage('build') { try { sh './gradlew build' } catch (Exception e) { bitbucketer.failed('build', e) } bitbucketer.succeeded() } }
As has already been reported on JENKINS-40150 and JENKINS-41442, the git repo information of the shared library is bleeding into the execution of the pipeline job. We have other pipeline operations that reference Git info, so I am unable to expand actual usage of the shared library to our other projects, with this interference.