docker agent选项对于共享库无效

时间:2019-05-03 19:23:58

标签: jenkins jenkins-pipeline jenkins-groovy

当我运行使用共享库的管道时,docker agent的

<head> <script> function create(type, style) { var container = document.createElement(type); container.classList.add(style); // Best way to add a class container.textContent = "Hello!"; let sibling = document.currentScript.nextElementSibling; if(sibling){ // Insert the new element before the next sibling sibling.parentNode.insertBefore(sibling, container) } else { // Insert the new element at the end of the body document.body.appendChild(container); } } </script> </head> <body> <p>The new element should be right below this.</p> <script> create("div", "someDiv"); </script> <p>The new element should be right above this.</p> </body>选项无效。

args

如果我推荐Invalid config option "call" for agent type "docker". Valid config options are [image, alwaysPull, args, containerPerStageRoot, customWorkspace, label, registryCredentialsId, registryUrl, reuseNode] @ line 30, column 25. args "-u root:root -v ${WORKSPACE}:${goPath}" ^ 选项,它将不会显示此错误。其他选项,例如argsimage正常工作。

在不使用共享库的情况下直接在jenkinsfile中使用它时,我没有问题。

goTest.groovy

reuseNode

jenkinsfile使用共享库

def call(){
      pipeline{
          stage('golang-install') {
                agent {
                    docker {
                        image 'SOME GOLANG IMAGE'
                        'args' "-u root:root -v ${WORKSPACE}:${goPath}"
                        reuseNode true
                    }
                }
                ...
           }
       }
   }

1 个答案:

答案 0 :(得分:0)

已解决。因为我将函数参数设置为args,所以它会覆盖args作为docker的选项。更改输入参数名称后,问题解决。 旧的

def call(Map args) {

}

一个新的

def call(Map opts) {

}