Setting build args for dockerfile agent using a Jenkins declarative pipeline

前端 未结 5 1192
名媛妹妹
名媛妹妹 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:35

    if you have admin access to Jenkins you can add these two script approvals:

    staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods execute java.lang.String
    staticMethod org.codehaus.groovy.runtime.ProcessGroovyMethods getText java.lang.Process
    

    in this URI: http://${jenkins_host:port}/jenkins/scriptApproval/

    which will allow you to execute a shell command in the master in this way:

    def user = 'id -u'.execute().text
    node {
       echo "Hello World ${user}"
    }
    

提交回复
热议问题