Added docker creds wrapper and updated git one
This commit is contained in:
		
							parent
							
								
									e3dc8ff249
								
							
						
					
					
						commit
						9c8cbb9e63
					
				| @ -44,6 +44,29 @@ def withGiteaCreds(String credentialsId, String gitToolName, Closure body) { | |||||||
|       gitToolName: gitToolName |       gitToolName: gitToolName | ||||||
|     ) |     ) | ||||||
|   ]) { |   ]) { | ||||||
|  |     sh "git config user.name ${env.GIT_USERNAME}" | ||||||
|  |     sh "git config user.email admin@dipal.ru" | ||||||
|  |     body() | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | /* -------------------------------------------------------------------------- */ | ||||||
|  | /** | ||||||
|  | * Wrapper function for `withCredentials` and `docker login` command. | ||||||
|  | * | ||||||
|  | * By passing existing `credentialsId` and link to `registry` will be | ||||||
|  | * extracted credentials from Jenkins and try to login to the registry | ||||||
|  | * using them. After all will be executed provided closure. | ||||||
|  | * | ||||||
|  | */ | ||||||
|  | def withDockerCreds(String credentialsId, String registry, Closure body) { | ||||||
|  |   withCredentials([ | ||||||
|  |     usernamePassword( | ||||||
|  |       credentialsId: credentialsId, | ||||||
|  |       usernameVariable: "DOCKER_LOGIN", | ||||||
|  |       passwordVariable: "DOCKER_PASSWORD", | ||||||
|  |     ) | ||||||
|  |   ]) { | ||||||
|  |     sh "docker login ${registry} -u ${DOCKER_LOGIN} -p ${DOCKER_PASSWORD}" | ||||||
|     body() |     body() | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user