From 2a6b1a235f8c3fd57e720b6e31a43b2a1d57e5da Mon Sep 17 00:00:00 2001 From: Tim Birkett Date: Wed, 27 Jan 2021 02:59:19 +0000 Subject: [PATCH] chore: tests and cleanup unnecessary assignments --- test/unit/groovy/vars/GetLibraryVersionTest.groovy | 2 +- vars/getLibraryVersion.groovy | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/groovy/vars/GetLibraryVersionTest.groovy b/test/unit/groovy/vars/GetLibraryVersionTest.groovy index 3ffbb2b..54440e2 100644 --- a/test/unit/groovy/vars/GetLibraryVersionTest.groovy +++ b/test/unit/groovy/vars/GetLibraryVersionTest.groovy @@ -16,7 +16,7 @@ class GetLibraryVersionTest extends PipelineSpockTestBase { def 'getLibraryVersion returns latest release tag when JOB_NAME matches LIBRARY_LATEST_JOB_MATCHER'() { given: addEnvVar('JOB_NAME', 'testing-pipeline') - addEnvVar('LIBRARY_LATEST_JOB_MATCHER', '^testing-') + addEnvVar('LIBRARY_LATEST_JOB_MATCHER', '^testing-|^my-cool-jobs') addEnvVar('LIBRARY_REPO', 'myorg/example-repo') helper.registerAllowedMethod('httpRequest', [Map], { map -> if (map.url == "https://api.github.com/repos/myorg/example-repo/releases/latest") { diff --git a/vars/getLibraryVersion.groovy b/vars/getLibraryVersion.groovy index 24ca75a..e4a0c9b 100644 --- a/vars/getLibraryVersion.groovy +++ b/vars/getLibraryVersion.groovy @@ -7,9 +7,9 @@ */ String call(Map conf = [:]) { // env variables should be set at the Jenkins Server level - String latestJobPattern = env.LIBRARY_LATEST_JOB_MATCHER ?: "" + String latestJobPattern = env.LIBRARY_LATEST_JOB_MATCHER - String libraryRepo = env.LIBRARY_REPO ?: "" + String libraryRepo = env.LIBRARY_REPO if(conf.libraryRepo) { libraryRepo = conf.libraryRepo } @@ -18,7 +18,7 @@ String call(Map conf = [:]) { String defaultStableLibraryVersion = env.LIBRARY_DEFAULT_STABLE_VERSION ?: "stable" String githubApiURL = env.GITHUB_API_URL ?: "api.github.com" - String githubCredentialsID = env.GITHUB_CREDENTIALS_ID ?: "" + String githubCredentialsID = env.GITHUB_CREDENTIALS_ID assert latestJobPattern assert libraryRepo