run jenkins pipeline agent with sudo

前端 未结 7 1613
一生所求
一生所求 2020-12-09 11:19

I have an Jenkins Server running in an docker container and have access to docker an the host system, so far it is working well. Now I want to set up a pipeline testing an s

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 11:43

    Same issue here where.

    [...]
    agent { docker 'whatever_I_try_doesnt_work'} # sudo, jenkins user in dockerroot group etc
    [...]
    

    So my workaround is to add it as one of the steps in the the build stage of the pipeline as follow:

    pipeline {
        agent any
        stages {
            stage('Build') {
                steps {
                    sh 'sudo docker pull python:3.5.1'
                }
            }
        }
    }
    

提交回复
热议问题