美文网首页
记录Mac下搭建Jenkins+GitLab持续集成环境遇到的坑

记录Mac下搭建Jenkins+GitLab持续集成环境遇到的坑

作者: 呆呆滴木木菇凉 | 来源:发表于2017-06-27 17:31 被阅读0次

    gitlab改版了,故运维同事们又迁移了jenkins,原本配好的可以成功打包的项目打包失败了。
    输出错误日志

    Started by user lhy
    Building in workspace /usr/share/tomcat8/.jenkins/workspace/zxpm
     > git rev-parse --is-inside-work-tree # timeout=10
    Fetching changes from the remote Git repository
     > git config remote.origin.url git@192.168.1.2:web/zxpm.git # timeout=10
    Fetching upstream changes from git@192.168.1.2:web/zxpm.git
     > git --version # timeout=10
    using GIT_SSH to set credentials 
     > git -c core.askpass=true fetch --tags --progress git@192.168.1.2:web/zxpm.git +refs/heads/*:refs/remotes/origin/*
    ERROR: Error fetching remote repo 'origin'
    hudson.plugins.git.GitException: Failed to fetch from git@192.168.1.2:web/zxpm.git
        at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:799)
        at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1055)
        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1086)
        at hudson.scm.SCM.checkout(SCM.java:485)
        at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
        at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
        at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
        at hudson.model.Run.execute(Run.java:1741)
        at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
        at hudson.model.ResourceController.execute(ResourceController.java:98)
        at hudson.model.Executor.run(Executor.java:410)
    Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress git@192.168.1.2:web/zxpm.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
    stdout: 
    stderr: Permission denied, please try again.
    Permission denied, please try again.
    Permission denied (publickey,password).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1740)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1476)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
        at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:797)
        ... 11 more
    ERROR: null
    Finished: FAILURE
    

    错误日志是我解决问题时找到跟我一模一样的错误信息(http://blog.csdn.net/lusyoe/article/details/52782368) ,不过他这个方法没有解决我的问题症结所在。
    抓住重要信息:
    stdout:
    stderr: Permission denied, please try again.
    Permission denied, please try again.
    Permission denied (publickey,password).
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.

    看这个说明是用户访问权限的问题。
    一开始琢磨还以为是选择的用户没有登录gitlab的权限,可是不是,因为之前jenkins打包是正常的,也是用的同样的配置用户。
    后来查找资料才发现,原来我在gitlab上配置的sshkey是用我的电脑我的用户生成的,而用jenkins打包的是在另外一台电脑上,故使用jenkins打包的电脑用户生成ssh公钥私钥来配置就可以了。
    参照:http://www.jianshu.com/p/ed0edb93e234

    相关文章

      网友评论

          本文标题:记录Mac下搭建Jenkins+GitLab持续集成环境遇到的坑

          本文链接:https://www.haomeiwen.com/subject/homecxtx.html