Skip to content

Commit

Permalink
Test a wider range of Jenkins versions in CI (#907)
Browse files Browse the repository at this point in the history
* Test a wider range of Jenkins versions in CI

* Java 17 with the most recent LTS - 2.361.1
* Java 11 with the previous LTS - 2.346.3
* Java 8 with the default provided by jenkins.version - 2.332.4

* Avoid NPE in authenticated merge call

Not expected to occur in most production environments, but the spotbugs
warning with Jenkins 2.361.1 is correct.  If the repository URL is
null as read from the default remote, then a null could be passed to
launchCommandWithCredentials.  Better to safeguard against passing null
to a method that is annotated to not accept null in that parameter.
  • Loading branch information
MarkEWaite authored Sep 14, 2022
1 parent 853f2df commit e73efbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildPlugin(failFast: false,
configurations: [
[platform: 'linux', jdk: 17, jenkins: '2.346.1'],
[platform: 'maven-11', jdk: 11],
[platform: 'linux', jdk: 17, jenkins: '2.361.1'],
[platform: 'maven-11', jdk: 11, jenkins: '2.346.3'],
[platform: 'windows', jdk: 8],
])
12 changes: 7 additions & 5 deletions src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -946,15 +946,17 @@ public void execute() throws GitException, InterruptedException {

/* See JENKINS-45228 */
/* Git merge requires authentication in LFS merges, plugin does not authenticate the git merge command */
String defaultRemote = null;
String repoUrl = null;
try {
defaultRemote = getDefaultRemote();
String defaultRemote = getDefaultRemote();
if (defaultRemote != null && !defaultRemote.isEmpty()) {
repoUrl = getRemoteUrl(defaultRemote);
}
} catch (GitException e) {
/* Nothing to do, just keeping defaultRemote = null */
/* Nothing to do, just keeping repoUrl = null */
}

if (defaultRemote != null && !defaultRemote.isEmpty()) {
String repoUrl = getRemoteUrl(defaultRemote);
if (repoUrl != null) {
StandardCredentials cred = credentials.get(repoUrl);
if (cred == null) cred = defaultCredentials;
launchCommandWithCredentials(args, workspace, cred, repoUrl);
Expand Down

0 comments on commit e73efbf

Please sign in to comment.