-
Notifications
You must be signed in to change notification settings - Fork 175
Fixes for minor defects with Jenkins flavor of the pipeline #148
Conversation
The jenkins/start.sh now recognizes option -key <path_to_private_key> and uses it to create the SSH Git credentials when starting new local Jenkins instance for the first time. The #137 is fixed by adding missed argument to the jenkins/Dockerfile. Also the documentation now reflects the additional parameter to start.sh
Added a unit test to reproduce the issue and refactored logic in the jenkins_pipeline_sample.groovy to use the new extension function to configure SCM block for all jobs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!! I've added some small remarks.
@@ -109,4 +111,8 @@ class ProjectCustomizerSpec extends Specification { | |||
} | |||
} | |||
|
|||
String filePath(String canonicalPath) { | |||
canonicalPath.replaceAll("/", Matcher.quoteReplacement(File.separator)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add return
? I personally always prefer it to be there in Groovy code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely!
@@ -43,11 +44,24 @@ String mySqlRootCredential = binding.variables["MYSQL_ROOT_CREDENTIAL_ID"] ?: "" | |||
String mySqlCredential = binding.variables["MYSQL_CREDENTIAL_ID"] ?: "" | |||
// remove::end[K8S] | |||
|
|||
ScmContext.metaClass.configureScm = { repoId, branchId -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think we can try to rewrite it in order no to use meta programming. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sth like (I don't really remember the correct classes)
Closure configureScm = { DslContext context, String repoId, String branchId ->
context.git {
remote {
name('origin')
url(repoId)
branch(branchId)
credentials(gitUseSshKey ? gitSshCredentials : gitCredentials)
}
extensions {
wipeOutWorkspace()
}
}
}
then you would call it like this
configureScm(delegate as DslContext, fullGitRepo, branchName)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could definitely do it if you have reservations about metaprogramming. The reason I like it in this scenario is that it basically uses the same mechanism as the Jenkins DSL itself thus making it look more natural. It also guarantees that we could only call the closure from the proper DSL block only and the error messages are more natural too if we misplace it.
What are your concerns about adding the closure directly to the ScmContext?
@@ -399,7 +369,7 @@ parsedRepos.each { | |||
allowEmpty() | |||
// remove::end[CF] | |||
} | |||
// end::start[K8S] | |||
// remove::end[K8S] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
@@ -43,11 +44,24 @@ String mySqlRootCredential = binding.variables["MYSQL_ROOT_CREDENTIAL_ID"] ?: "" | |||
String mySqlCredential = binding.variables["MYSQL_CREDENTIAL_ID"] ?: "" | |||
// remove::end[K8S] | |||
|
|||
Closure configureScm = { ScmContext context, String repoId, String branchId -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bootifull!
The fixes are provided for the following defects: