Skip to content

Fix reporting status on first build when using multibranch pipelines #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 26 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<!-- Baseline Jenkins version you use to build and test the plugin. Users must have this version or newer to run. -->
<version>1.609.1</version>

<version>4.46</version>
<relativePath />
</parent>

Expand All @@ -15,11 +15,11 @@
<packaging>hpi</packaging>

<properties>
<maven-release-plugin.version>2.5.1</maven-release-plugin.version>
<maven-hpi-plugin.version>1.112</maven-hpi-plugin.version>
<maven-deploy-plugin.version>2.6</maven-deploy-plugin.version>
<wagon-http.version>2.10</wagon-http.version>
<workflow.version>1.11</workflow.version>
<workflow.version>2.80</workflow.version>
<!-- Baseline Jenkins version you use to build and test the plugin. Users must have this version or newer to run. -->
<jenkins.version>2.387.3</jenkins.version>
<java.version>8</java.version>
</properties>

<name>Bitbucket Build Status Notifier Plugin</name>
Expand Down Expand Up @@ -74,77 +74,63 @@
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.387.x</artifactId>
<version>2244.vd60654536b_96</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mercurial</artifactId>
<version>1.54</version>
<version>1260.vdfb_723cdcc81</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>${workflow.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>

</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<classifier>tests</classifier>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<classifier>tests</classifier>
<version>${workflow.version}</version>
<scope>test</scope>

</dependency>


<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
<version>2.10.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<version>1.3.3</version>
<version>1.3.7</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.22</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>display-url-api</artifactId>
<version>0.4</version>
</dependency>
</dependencies>

Expand All @@ -153,7 +139,6 @@
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>${maven-hpi-plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
Expand All @@ -166,7 +151,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<goals>deploy</goals>
</configuration>
Expand All @@ -175,7 +159,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven-deploy-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.jenkinsci.plugins.bitbucket.validator.BitbucketHostValidator;
import org.jenkinsci.plugins.displayurlapi.DisplayURLProvider;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.scribe.model.*;

class BitbucketBuildStatusHelper {
Expand Down Expand Up @@ -134,7 +135,13 @@ public static List<BitbucketBuildStatusResource> createBuildStatusResources(fina
Job<?, ?> project = build.getParent();
List<BitbucketBuildStatusResource> buildStatusResources = new ArrayList<BitbucketBuildStatusResource>();

if (project instanceof WorkflowJob) {
if (build instanceof WorkflowRun) {
Collection<? extends SCM> scms = ((WorkflowRun)build).getSCMs();

for (SCM scm : scms) {
buildStatusResources.addAll(createBuildStatusResources(scm, build));
}
} else if (project instanceof WorkflowJob) {
Collection<? extends SCM> scms = ((WorkflowJob)project).getSCMs();

for (SCM scm : scms) {
Expand Down