Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jenkins - git step working, but checkout scm is not - going crazy :-)

After looking through the net for some time now and trying different options for an entire night, he he. I decided to ask some adults out here :-) what could be wrong with what I am doing - what am I missing. I probably missed something simple..

Inside my pipeline I have a simple git step - it is working perfectly:

git( url: "${gitConfigRepo}", credentialsId: "mysecret", branch: "master" )

I actually needed to do a submodule checkout - however after trying something like this:

    sh( script: "git submodule update --init --remote mysubmodule" )

which was not working (git was complaining about credentials), so I did my usual trick (copied from a wise man from stack overflow at some point many years ago):

withCredentials( [ usernamePassword( credentialsId: "mysecret", usernameVariable: "GIT_USERNAME", passwordVariable: 'GIT_PASSWORD' ) ] ) {
    sh "git config --local credential.username '${env.GIT_USERNAME}'"
    sh "git config --local credential.helper '!echo password=${env.GIT_PASSWORD}; echo'"
    sh( script: "git submodule update --init --remote mysubmodule" )
    sh "git config --local --remove-section credential"
}

Which resulted in mindblowing an annoying message:

fatal: could not read Username for '<server>': No such device or address
fatal: clone of '<server>/mysubmodule.git' into submodule path '/tmp/workspace/test/mysubmodule' failed
Failed to clone 'api-platform-verification-v1'. Retry scheduled
Cloning into '/tmp/workspace/test/musubmodule'...
fatal: could not read Username for '<server>': No such device or address
fatal: clone of '<server>/mysubmodule.git' into submodule path '/tmp/workspace/test/mysubmodule' failed
Failed to clone 'mysubmodule' a second time, aborting

(also tried without the credentials block - but then I just got the same error)

I decided to go another way, using the checkout scm - that I have used so many times before.. It can initialize all submodules - even though I only need ONE of the 20 in there - it was my MOST desperate hour, he he...

So rolled everything back - and tried a simple checkout scm:

checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[credentialsId: 'mysecret', url: "${gitConfigRepo}"]],
    branches: [[name: "master"]]],
    changelog: true,
    poll: false                     

And this is also not working.. Output is as follows:

using credential api-contracts-git-auth-secret
Cloning the remote Git repository
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress -- <myserver> +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: remote error: Repository not found
The requested repository does not exist, or you do not have permission to
access it.

Which is a lie, he he - I am doing this in other pipelines :-) On the same Jenkins instance.. The same git fetch command is working perfectly in the first example (it is outputted in the log).....

So now I am turning to all you much wiser persons out there :-)

What am I not seeing.. I have done this a 1000 times, he he.. Help on the latter would be great - but on the submodule cloning - if you have an idea on that - it would also be great..

question from:https://stackoverflow.com/questions/65940298/git-step-working-but-checkout-scm-is-not-going-crazy

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...