Setting build args for dockerfile agent using a Jenkins declarative pipeline

前端 未结 5 1213
名媛妹妹
名媛妹妹 2020-12-31 00:56

I\'m using the declarative pipeline syntax to do some CI work inside a docker container.

I\'ve noticed that the Docker plugin for Jenkins runs a container using the

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 01:18

    You can also use the args parameter to solve the issue.
    As described in Pipeline Syntax:

    docker also optionally accepts an args parameter which may contain arguments to pass directly to a docker run invocation.

    This is also possible when using dockerfile instead of docker in agent section.

    I had the same problem like you and the following lines working fine for me:

           agent { 
                dockerfile { 
                    dir 'Docker/kubernetes-cli' 
                    args '-u 0:0' //Forces Container tu run as User Root                    
                    reuseNode true
                }
            }
    

提交回复
热议问题