How do you provide a managed file to a Jenkins build using docker.image?

巧了我就是萌 提交于 2019-12-24 12:12:56

问题


I am trying to use Jenkins Pipelines to build a Maven Java project and deploy its artifacts into Nexus. The Nexus credentials are managed by Jenkins, so I need Jenkins to provide the Maven settings.xml file. My pipeline uses docker to run the build. My Jenkinsfile looks like:

node('docker') {
   git 'git@bitbucket.org:myorg/myproject.git'

   stage 'Build and Test' 
   // This throws: java.lang.UnsupportedOperationException: Refusing to marshal org.codehaus.groovy.runtime.InvokerInvocationException for security reasons
    //configFileProvider([configFile(fileId: '7d6efcd2-ff3d-43dc-be40-898dab2bff64', variable: 'MYSETTINGS')]) {
    //    sh 'cp ${MYSETTINGS} mysettings.xml'
    // }

    docker.image('maven:3.3.9').inside {
        // sh 'mvn -s mysettings.xml -U -e clean deploy'
        // This fails trying to access AWS ECR (???)
        withMaven(mavenSettingsConfig: '7d6efcd2-ff3d-43dc-be40-898dab2bff64') {
            sh 'mvn -U -e clean deploy'
    }
}

So far I am unable to provide the correct maven settings. There are some 'Knows limitation' on the withMaven (Maven Pipeline Plugin, https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Maven+Plugin)

Is there a workaround ? I tried to use the configFileProvider, but it throws UnsupportedOperationException because of security reasons.

来源:https://stackoverflow.com/questions/41110028/how-do-you-provide-a-managed-file-to-a-jenkins-build-using-docker-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!