docker - 在 Jenkins 中使用 Jekyll docker

标签 docker jenkins jenkins-pipeline jekyll

我正在尝试通过我的 Jenkins 服务器(在容器内运行)构建一个 jekyll 网站,我的 Jenkinsfile 中有一个阶段,如下所示:

stage('Building Website') {

      agent {

        docker {
            image 'jekyll/jekyll:builder'
        }

      }

      steps {
        sh 'jekyll --version'
      }
}

我第一次运行我的工作时,它拉取了 jekyll docker 镜像并运行良好(尽管它在运行 jekyll 之前确实获取了一堆 gems,这在我在 jenkins 之外手动运行 docker 时不会发生)但是接下来作业失败并给出此错误:

jekyll --version
/usr/jekyll/bin/jekyll: exec: line 15: /usr/local/bundle/bin/jekyll: not found

知道我在这里做错了什么吗?

最佳答案

正如您在 jenkins 日志文件中看到的那样,jenkins 使用 -u 1000:1000 参数运行 docker,因为该用户没有退出 jekyll/jekyll图像,命令失败并出现错误 .../bin/jekyll: not found

这是一个示例 Jenkinsfile:

pipeline {
    agent
    {
        docker
        {
            image 'jekyll/jekyll:3.8'
            args '''
                -u root:root
                -v "${WORKSPACE}:/srv/jekyll"
            '''
        }
    }
    stages {
        stage('Test') {
            steps {
                sh '''
                    cd /srv/jekyll
                    jekyll --version
                '''
            }
        }
    }
}

关于docker - 在 Jenkins 中使用 Jekyll docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53653112/

相关文章:

python - 无法在 docker 容器内安装 pip azure-cognitiveservices-speech

docker - 简单地说,运行本身运行docker容器的任务的最简单方法是什么?

jenkins - 我可以 "import"Jenkins 声明性管道中的阶段吗

jenkins-pipeline - 如何在 groovy 中使用配置文件提供程序插件

python - sqlalchemy.exc.OperationalError : (psycopg2. OperationalError) 与 PostgreSQL

java - 容器中运行的java程序内部的Docker主机IP

ios - jenkins build of unity 出现错误

Jenkins Post 构建部署

postgresql - 在 Jenkins 中使用 docker Container 链接

Jenkinsfile 管道错误 : "expected a symbol" and "undefined section"