Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bitnami Jenkins VM:为什么管道在第二次运行时尝试签出git回购时缺少权限?_Git_Jenkins_Jenkins Pipeline - Fatal编程技术网

Bitnami Jenkins VM:为什么管道在第二次运行时尝试签出git回购时缺少权限?

Bitnami Jenkins VM:为什么管道在第二次运行时尝试签出git回购时缺少权限?,git,jenkins,jenkins-pipeline,Git,Jenkins,Jenkins Pipeline,这是我的第一个问题,请记住 我正在本地机器上使用Bitnami Jenkins虚拟机与Jenkins玩arround游戏,稍后我想将其引入我的公司 我在回购协议中通过Jenkinsfile建立了一个管道,如下所示: pipeline { agent { docker { image 'apmyp1990/lamp' args '-u root' } } stages { sta

这是我的第一个问题,请记住

我正在本地机器上使用Bitnami Jenkins虚拟机与Jenkins玩arround游戏,稍后我想将其引入我的公司

我在回购协议中通过Jenkinsfile建立了一个管道,如下所示:

pipeline {
    agent {
        docker {
            image 'apmyp1990/lamp'
            args '-u root'
        }
    }
    stages {
        stage('Build') {
            steps {
                sh 'service mysql start'
                sh 'mysql -u root -proot -e "DROP DATABASE IF EXISTS text_db; CREATE DATABASE test_db;"'
                sh 'mysql -u root -proot -e "show databases;"'
                sh 'mysql -u root -proot -e "use test_db; source database/2018-06-26.sql;"'
                sh 'composer update'
                sh 'nightwatch'
            }
        }
    }
}
第一次运行此管道时,它无法启动docker,但我只是将用户
tomcat
(jenkins正在与此用户一起运行)添加到docker组。在第一次跑步中,一切都很好(尽管夜视没有启动,但这不是问题)。当我第二次尝试运行此管道时,出现以下错误:

Started by user admin
Obtained jenkinsfile from git https://bitbucket.org/{PROJECTNAME}.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /opt/bitnami/apps/jenkins/jenkins_home/workspace/{Project}
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
 > /opt/bitnami/git/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /opt/bitnami/git/bin/git config remote.origin.url https://bitbucket.org/{PROJECTNAME}.git # timeout=10
Fetching upstream changes from https://bitbucket.org/{PROJECTNAME}.git
 > /opt/bitnami/git/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials Arturs Bitbucket Account
 > /opt/bitnami/git/bin/git fetch --tags --progress https://bitbucket.org/{PROJECTNAME}.git +refs/heads/*:refs/remotes/origin/*
 > /opt/bitnami/git/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > /opt/bitnami/git/bin/git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision a9acc7b417f410ad4b3b8b73aeb905e7ace7df2b (refs/remotes/origin/master)
 > /opt/bitnami/git/bin/git config core.sparsecheckout # timeout=10
 > /opt/bitnami/git/bin/git checkout -f a9acc7b417f410ad4b3b8b73aeb905e7ace7df2b
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.plugins.git.GitException: Command "/opt/bitnami/git/bin/git checkout -f a9acc7b417f410ad4b3b8b73aeb905e7ace7df2b" returned status code 1:
stdout: 
stderr: error: unable to unlink old 'web/typo3conf/ext/dce/Classes/Components/BackendView/SimpleBackendView.php': Permission denied
error: unable to unlink old 'web/typo3conf/ext/dce/Classes/Components/DceContainer/Container.php': Permission denied
{much more of permission denied errors}

Previous HEAD position was 606c9db lamp:latest
HEAD is now at a9acc7b add root user

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$800(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2301)
Caused: hudson.plugins.git.GitException: Could not checkout a9acc7b417f410ad4b3b8b73aeb905e7ace7df2b
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2325)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1236)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
    at hudson.security.ACL.impersonate(ACL.java:290)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
然后,我通过bash检查了权限(请参阅链接图片,因为我无法从debian bash复制):

为了让管道正常运行,我遗漏了什么?我不明白为什么Jenkins的权限有问题——Jenkins是用用户tomcat运行的,所以一切都应该正常

编辑:

我发布了错误的Jenkins文件,它应该在代理部分有
args'-u root'
命令(见上文)。 我现在发现,使用此命令运行管道会导致错误。但是,当我不使用此命令时,由于缺少权限,我无法启动mysql服务器。 第一次启动管道(新创建的管道)而没有
args'-u root'
,启动mysql服务器失败,但下次使用args命令运行管道不会产生任何错误。有什么建议吗


提前谢谢你

作业的工作区是否为空,您是否能够重新启动jenkins?我知道这有点激烈,但有一次当一个进程仍在作业中运行时(我中止了它)@lvthillo我可以重新启动Jenkins,但作业的工作区不是空的。如果我创建了一个新作业,它第一次通过,但是第二次和以后的每一次都会失败,权限被拒绝。我发现我的docker映像的配置可能有问题,但我不能说是什么导致了这个问题。