We have a Jenkins configured to use Github app to perform all Git related activities. A project of ours uses the Nebula Gradle plugin for release process. So, whenever the final
task runs on Jenkins, the first Gradle task that runs is prepare
which performs a git fetch
using the internal JGit. In doing so it fails with the following exception:
org.eclipse.jgit.errors.TransportException: https://github.com/yyy/zzz.git: Authentication is required but no CredentialsProvider has been registered
So, the question is - how do I make the nebula plugin to use the credentials provided by the Github App configured on Jenkins?
Configure your Jenkinsfile
as follows:
steps {
withCredentials([usernamePassword(credentialsId: 'github-app-id',
usernameVariable: 'GITHUB_APP',
passwordVariable: 'GITHUB_ACCESS_TOKEN')]) {
sh 'export GRGIT_USER=$GITHUB_APP && export GRGIT_PASS=$GITHUB_ACCESS_TOKEN && ./gradlew final'
}
}