Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Fixes for minor defects with Jenkins flavor of the pipeline #148

Merged
merged 5 commits into from
Mar 2, 2018
Merged

Fixes for minor defects with Jenkins flavor of the pipeline #148

merged 5 commits into from
Mar 2, 2018

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.
Fixed typos in the marker of the end of the K8S block for removal.

Fixed pipeline tests to not assume existence of either K8S or CF
scripts.

Fixed JobScripts tests to only verify availability of the CF/K8S jobs in
case of them not being excluded during the customization.
Copy link
Contributor

@marcingrzejszczak marcingrzejszczak left a 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))
Copy link
Contributor

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

Copy link
Contributor Author

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 ->
Copy link
Contributor

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?

Copy link
Contributor

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)

Copy link
Contributor Author

@oiavorskyi oiavorskyi Mar 1, 2018

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]
Copy link
Contributor

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 ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootifull!

@marcingrzejszczak marcingrzejszczak merged commit ee405c7 into spring-attic:master Mar 2, 2018
@marcingrzejszczak marcingrzejszczak added this to the 1.0.0.M8 milestone Mar 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants