一尘不染

Jenkinsfile CIFSPublisher不使用通配符复制正确的文件

jenkins

在我的Jenkins脚本化管道中,我尝试使用cifsPublisher将文件复制到远程Windows共享

如此处所述我应该将其myPrj/deploy/**/*用作sourceFiles模式,但不要复制希望复制的文件。

这是我的Jenkinsfile步骤:

stage('Save WAR'){
    //
    sh 'ls -laR ./myPrj/deploy/'
    //
    cifsPublisher(publishers: [[
        configName: 'myConfig',
        transfers: [[cleanRemote: false,
            excludes: '',
            flatten: false,
            makeEmptyDirs: true,
            noDefaultExcludes: false,
            patternSeparator: '',
            remoteDirectory: 'Server',
            remoteDirectorySDF: false,
            removePrefix: '',
            sourceFiles: './myPrj/deploy/**/*' ]],
        usePromotionTimestamp: false,
        useWorkspaceInPromotion: false,
        verbose: true]])        
}

这是详细的输出:

+ ls -laR ./myPrj/deploy/
./myPrj/deploy/:
totale 0
drwxr-xr-x  3 jenkins jenkins  41 ago  3 11:55 .
drwxr-xr-x 11 jenkins jenkins 299 ago  3 11:56 ..
drwxr-xr-x  2 jenkins jenkins  65 ago  3 11:57 myPrj-01.01.01-201808031155

./myPrj/deploy/myPrj-01.01.01-201808031155:
totale 443392
drwxr-xr-x 2 jenkins jenkins        65 ago  3 11:57 .
drwxr-xr-x 3 jenkins jenkins        41 ago  3 11:55 ..
-rw-r--r-- 1 jenkins jenkins 269154173 ago  3 11:57 Dist.zip
-rw-r--r-- 1 jenkins jenkins       168 ago  3 11:55 INFO.txt
-rw-r--r-- 1 jenkins jenkins 184870342 ago  3 11:57 myPrj##01.01.01.war
[Pipeline] cifsPublisher
CIFS: Connecting from host [jenkins]
CIFS: Connecting with configuration [myConfig] ...
CIFS: Removing WINS from name resolution
CIFS: Setting response timeout [30.000]
CIFS: Setting socket timeout [35.000]
CIFS: Setting buffer size to: [4.096] Bytes
CIFS: copy [smb://WinServer/SHARE/Jenkins/Server/.com.apple.timemachine.supported]
CIFS: copy [smb://WinServer/SHARE//Jenkins/Server/Jenkinsfile]
CIFS: copy [smb://WinServer/SHARE/Jenkins/Server/build.gradle]
CIFS: copy [smb://WinServer/SHARE/Jenkins/Server/gradlew]
CIFS: copy [smb://WinServer/SHARE/Jenkins/Server/gradlew.bat]
CIFS: copy [smb://WinServer/SHARE/Jenkins/Server/sonar-project.properties]
CIFS: copy [smb://WinServer/SHARE/Jenkins/Server/vstop.png]
CIFS: Disconnecting configuration [myConfig] ...
CIFS: Transferred 7 file(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

复制的文件来自工作区根目录。

我在哪里做错了?


阅读 400

收藏
2020-07-25

共1个答案

一尘不染

我不知道这是否是一个错误,但我发现了一种使用dir并设置patternSeparator/

stage('Save WAR'){
    dir('myPrj/deploy/') {
        cifsPublisher(publishers: [[
            configName: 'myConfig',
            transfers: [[cleanRemote: false,
                excludes: '',
                flatten: false,
                makeEmptyDirs: true,
                noDefaultExcludes: false,
                patternSeparator: '/',
                remoteDirectory: "Server/",
                remoteDirectorySDF: false,
                removePrefix: '',
                sourceFiles: '**/*' ]],
            usePromotionTimestamp: false,
            useWorkspaceInPromotion: false,
            verbose: true]]
        )
    }
}
2020-07-25