Open Wilfred opened 7 years ago
Hi, @Wilfred
Can you try override projectKey
value for the notifier manually for your needs for both jobs?
Yep, setting the projectKey
for just one job of my two jobs works as a solution.
However, this requires every user with multiple jobs that are multibranch pipelines to do the same thing. Ideally stashnotifier-plugin wouldn't require every user to set projectKey
or prependParentProjectKey
.
Initially, prepend parent job key option was introduced in #60 by me for solving your initial problem - create unique keys for multibranch projects operating the same repo. I'm not sure that configuring single option is a really big problem to make this plugin hardly tied to multibranch plugin. If you have a decision without declaring a dependency - PR is always welcome
@scaytrase OK, how about this?
If env.BRANCH_NAME
is the same as the project name, then we automatically prepend the parent job key?
How do you resolve false positives, i.e classic non-multibranch job, named master
building only master
branch?
I think it's ok to introduce some optional global-configured project key guesser, but it should be off by default anyway for BC reasons to not get any key renamed unintentionally
If there's a classic non-multibranch job named master
, prepending the parent job key is harmless because StashNotifier handles the parent being null.
If the classic non-multibranch job is in a folder, then the the parent job key will be non-null, but that seems harmless to me.
Suppose I have two separate multibranch pipeline jobs,
foo-unit
andfoo-integration
. When I push a branch to master, the following notifications are sent to Stash:These both have the same
key
. As a result, Stash uses the last build and ignores the first.I can't use
includeBuildNumberInKey
because if build 1 of foo-integration is red, but build 2 of foo-integration is green, Stash thinks they are distinct jobs. This gives a key of the form"master-2-http:\\/\\/ci.dev.example\\/"
.If I use
step([$class: 'StashNotifier', prependParentProjectKey: true])
I get a key that's unique to the current build:However, this is subtle gotcha. It would be nice if this plugin used the build name, not the branch name, for multibranch pipelines.
I think the correct solution would be to change
StashNotifier#getDefaultBuildKey
to use something likeif build instanceOf MultiBranchProject
, but this would introduce a dependency on that plugin.What do you think is a good solution here?