<% credentials.each do |cred| %> sh "git config --global credential.<%= cred.protocol %>://<%= cred.host %>.helper cache" withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: '<%= cred.jenkins_id %>', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { def credentials = "protocol=<%= cred.protocol %>\nhost=<%= cred.host %>\nusername=${env.USERNAME}\npassword=${env.PASSWORD}\n" sh "echo '${credentials}' | git credential approve" } <% end %>