Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jenkinsci/gitlab-plugin i…
Browse files Browse the repository at this point in the history
…nto fix/missing-defined-variables
  • Loading branch information
krisstern committed May 29, 2023
2 parents 947445a + bcaa2cf commit c39ff4d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/sync-project-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Sync project branch
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync-project-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: gsoc-2023-project
- run: |
git fetch --unshallow origin || git fetch origin
git config user.email "[email protected]"
git config user.name "Sync project branch action"
git merge --no-edit origin/master
- uses: peter-evans/create-pull-request@v5
with:
title: Merge remote-tracking branch `origin/master` into `gsoc-2023-project`
branch: sync-project-branch
delete-branch: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ work
.project
.settings
.DS_Store
META-INF/
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.62</version>
<version>4.63</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -50,7 +50,7 @@
</distributionManagement>

<properties>
<revision>1.7.13</revision>
<revision>1.7.15</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.375.4</jenkins.version>
<spotbugs.effort>Max</spotbugs.effort>
Expand All @@ -67,7 +67,7 @@
<!-- Pick up common dependencies for the selected LTS line: https://github.com/jenkinsci/bom#usage -->
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.361.x</artifactId>
<version>2062.v154408a_24d20</version>
<version>2102.v854b_fec19c92</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -420,7 +420,7 @@
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.42.1</version>
<version>0.43.0</version>
<configuration>
<verbose>true</verbose>
<images>
Expand Down Expand Up @@ -504,7 +504,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<executions>
<execution>
<id>add-source</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ public static void updateCommitStatus(
return;
}

EnvVars environment = null;
if (gitLabBranchBuilds == null || gitLabBranchBuilds.isEmpty()) {
try {
if (!build.getEnvironment(listener).isEmpty()) {
gitLabBranchBuilds = retrieveGitlabProjectIds(build, build.getEnvironment(listener));
environment = build.getEnvironment(listener);
if (!environment.isEmpty()) {
gitLabBranchBuilds = retrieveGitlabProjectIds(build, environment);
}
} catch (IOException | InterruptedException e) {
printf(listener, "Failed to get Gitlab Build list to update status: %s%n", e.getMessage());
Expand Down Expand Up @@ -96,7 +98,7 @@ public static void updateCommitStatus(
gitLabBranchBuild.getProjectId(),
gitLabBranchBuild.getRevisionHash(),
state,
getBuildBranchOrTag(build),
getBuildBranchOrTag(build, environment),
current_build_name,
buildUrl,
state.name());
Expand Down Expand Up @@ -155,10 +157,10 @@ private static boolean existsCommit(GitLabClient client, String gitlabProjectId,
}
}

private static String getBuildBranchOrTag(Run<?, ?> build) {
private static String getBuildBranchOrTag(Run<?, ?> build, EnvVars environment) {
GitLabWebHookCause cause = build.getCause(GitLabWebHookCause.class);
if (cause == null) {
return null;
return environment == null ? null : environment.get("BRANCH_NAME", null);
}
if (cause.getData().getActionType() == CauseData.ActionType.TAG_PUSH) {
return StringUtils.removeStart(cause.getData().getSourceBranch(), "refs/tags/");
Expand Down

0 comments on commit c39ff4d

Please sign in to comment.