I want to git pull
a project in GitLab via bash in Jenkins pipeline. It looks something like this:
pipeline {
agent any
stages {
stage('build') {
steps {
git branch: 'develop',
credentialsId: '12345-123-123123-1f54-123141e67c',
url: 'ssh://git@gitlab.blabla:PORT/group/project.git'
sh 'cd /var/www/project/'
sh 'git pull origin develop'
}
}
}
}
But it requires inserting a username and password for every request. I find out about adding the credentials using these ways that stated in this SO discussion.
But using git config credential.helper
will store the credentials in plain text which is it is not safe. And also cloning the project with the username and password in the git URL like this https://user:pass@domain/repo
is also not safe.
Is there any way to do it securely?