jenkinsci / jenkinsci/git-plugin
[JENKINS-46052] GIT: UserIdentity does not work on pipeline
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
A pipeline job with checkout configured as :
checkout ([poll: false,
scm: [$class: 'GitSCM',
branches: [[name: '$GERRIT_BRANCH']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'WipeWorkspace'],
[$class: 'BuildChooserSetting',
buildChooser: [$class: 'GerritTriggerBuildChooser']],
[$class: 'UserIdentity',
email: 'jenkins@',
name: 'Jenkins (NICOS release job)']
],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'XXXXX',
refspec: '$GERRIT_REFSPEC',
url: 'ssh:///$GERRIT_PROJECT']]
]
]
give the following log output:
[Pipeline] checkout
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository ssh:///
> /usr/bin/git init /home/jenkins/jobs/XXXX/workspace # timeout=10
Fetching upstream changes from ssh:///
> /usr/bin/git --version # timeout=10
using GIT_SSH to set credentials XXXXX
> /usr/bin/git fetch --tags --progress ssh:/// +refs/heads/*:refs/remotes/origin/*
> /usr/bin/git config remote.origin.url ssh:/// # timeout=10
> /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git config remote.origin.url ssh:/// # timeout=10
Fetching upstream changes from ssh:///
using GIT_SSH to set credentials XXXXXXXXXX
> /usr/bin/git fetch --tags --progress ssh:/// refs/heads/release-3.0
> /usr/bin/git rev-parse FETCH_HEAD^{commit} # timeout=10
Checking out Revision eb56ef5e23cebf5ba496421b32fcd650c503402d ($GERRIT_BRANCH)
Commit message: "simulation: do not emit warning if quiet"
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f eb56ef5e23cebf5ba496421b32fcd650c503402d
> /usr/bin/git rev-parse FETCH_HEAD^{commit} # timeout=10
> /usr/bin/git rev-list cef586346270967a0435d76501053395197cf6a5 # timeout=10
[Pipeline] }
As you can see, the user.name/email are never set.
With docker.image.inside, this results in the following error later on:
*** Please tell me who you are.Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: empty ident name (for ) not allowed
Workaround: Add a sh step to configure the repo
sh '''
git config user.email "jenkins@"
git config user.name "Jenkins (NICOS release job)"
'''
---
Originally reported by pedersen, imported from: GIT: UserIdentity does not work on pipeline
Raw content of original issue
A pipeline job with checkout configured as :
checkout ([poll: false,
scm: [$class: 'GitSCM',
branches: [[name: '$GERRIT_BRANCH']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'WipeWorkspace'],
[$class: 'BuildChooserSetting',
buildChooser: [$class: 'GerritTriggerBuildChooser']],
[$class: 'UserIdentity',
email: 'jenkins@<domain>',
name: 'Jenkins (NICOS release job)']
],
gitTool: 'Default',
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'XXXXX',
refspec: '$GERRIT_REFSPEC',
url: 'ssh://<host>/$GERRIT_PROJECT']]
]
]give the following log output:
[Pipeline] checkout
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository ssh://<host>/<project>
> /usr/bin/git init /home/jenkins/jobs/XXXX/workspace # timeout=10
Fetching upstream changes from ssh://<host>/<project>
> /usr/bin/git --version # timeout=10
using GIT_SSH to set credentials XXXXX
> /usr/bin/git fetch --tags --progress ssh://<host>/<project> +refs/heads/*:refs/remotes/origin/*
> /usr/bin/git config remote.origin.url ssh://<host>/<project> # timeout=10
> /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> /usr/bin/git config remote.origin.url ssh://<host>/<project> # timeout=10
Fetching upstream changes from ssh://<host>/<project>
using GIT_SSH to set credentials XXXXXXXXXX
> /usr/bin/git fetch --tags --progress ssh://<host>/<project> refs/heads/release-3.0
> /usr/bin/git rev-parse FETCH_HEAD^{commit} # timeout=10
Checking out Revision eb56ef5e23cebf5ba496421b32fcd650c503402d ($GERRIT_BRANCH)
Commit message: "simulation: do not emit warning if quiet"
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f eb56ef5e23cebf5ba496421b32fcd650c503402d
> /usr/bin/git rev-parse FETCH_HEAD^{commit} # timeout=10
> /usr/bin/git rev-list cef586346270967a0435d76501053395197cf6a5 # timeout=10
[Pipeline] }As you can see, the user.name/email are never set.
With docker.image.inside, this results in the following error later on:
*** Please tell me who you are.Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: empty ident name (for <jenkins@67b4ac9c6b46.(none)>) not allowed
Workaround: Add a sh step to configure the repo
sh '''
git config user.email "jenkins@<domain>"
git config user.name "Jenkins (NICOS release job)"
'''
- environment:
Linux, primary checkout in normal node, work done in docker (docker.image.inside...)
Contributor guide
Assessment
This issue has not been assessed yet.