jenkinsci / jenkinsci/workflow-basic-steps-plugin
[JENKINS-53374] file permissions are lost after unstashing on windows node
- Lingua principale
- Java
- Stelle
- 73
- Fork
- 129
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Consider the following script:
node( 'macos' ) {
sh 'rm -rf *'
sh 'echo "int main() { return 0; }" > test.cpp'
sh 'mkdir bin && gcc test.cpp -o bin/test'
sh "ls -l bin"
stash name:'test', includes: "bin/*"
}node( 'windows' ) {
unstash 'test'
stash name:'test2', includes: 'bin/*'
}node( 'linux' ) {
sh 'rm -rf *'
unstash 'test2'
sh "ls -l bin"
}
It produces the following output:
Started by user Nenad Mikša
Running in Durability level: PERFORMANCE_OPTIMIZED
[Pipeline] node
Running on macpro2 in /opt/jenkins/workspace/Test
[Pipeline] {
[Pipeline] sh
[Test] Running shell script
+ rm -rf bin test.cpp
[Pipeline] sh
[Test] Running shell script
+ echo 'int main() { return 0; }'
[Pipeline] sh
[Test] Running shell script
+ mkdir bin
+ gcc test.cpp -o bin/test
[Pipeline] sh
[Test] Running shell script
+ ls -l bin
total 16
-rwxr-xr-x 1 pero staff 4248 Aug 31 20:40 test
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
[Pipeline] // node
[Pipeline] node
Running on Jabba in C:\Jenkins\workspace\Test
[Pipeline] {
[Pipeline] unstash
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
[Pipeline] // node
[Pipeline] node
Running on blade in /opt/jenkins/root/workspace/Test
[Pipeline] {
[Pipeline] sh
[Test] Running shell script
+ rm -rf test.sh
[Pipeline] unstash
[Pipeline] sh
[Test] Running shell script
+ ls -l bin
total 8
-rw-r--r-- 1 jenkins users 4248 Aug 31 20:40 test
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
So, after unstashing the unix binary on windows node and stashing it back, it loses its unix file permissions.
Since windows does not have unix file permissions, I would expect that on windows would treat all files in 777 mode, especially after stashing back.
In case if you are wondering why is this important to me, here is the explanation:
I use Jenkins to build Conan packages of my software. The binaries are first built on various nodes for various platforms (windows, linux, macos, android and ios) and after binaries for every platform have been built successfully, they are all collected on first available node using the stash/unstash mechanism and there they are packaged and uploaded to Conan repository.
Due to this issue this causes for binaries that are built on unix nodes lose their file permissions if they are packaged on windows node. A possible workaround would be to enforce packaging on unix node or to perform some partial packaging on nodes that have created the binaries. As these workarounds work for me, I've set priority of this issue as "minor".
---
Originally reported by
dodoent, imported from: file permissions are lost after unstashing on windows node
Raw content of original issue
Consider the following script:
node( 'macos' ) {
sh 'rm -rf *'
sh 'echo "int main() { return 0; }" > test.cpp'
sh 'mkdir bin && gcc test.cpp -o bin/test'
sh "ls -l bin"
stash name:'test', includes: "bin/*"
}node( 'windows' ) {
unstash 'test'
stash name:'test2', includes: 'bin/*'
}node( 'linux' ) {
sh 'rm -rf *'
unstash 'test2'
sh "ls -l bin"
}It produces the following output:
Started by user Nenad Mikša
Running in Durability level: PERFORMANCE_OPTIMIZED
[Pipeline] node
Running on macpro2 in /opt/jenkins/workspace/Test
[Pipeline] {
[Pipeline] sh
[Test] Running shell script
+ rm -rf bin test.cpp
[Pipeline] sh
[Test] Running shell script
+ echo 'int main() { return 0; }'
[Pipeline] sh
[Test] Running shell script
+ mkdir bin
+ gcc test.cpp -o bin/test
[Pipeline] sh
[Test] Running shell script
+ ls -l bin
total 16
-rwxr-xr-x 1 pero staff 4248 Aug 31 20:40 test
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
[Pipeline] // node
[Pipeline] node
Running on Jabba in C:\Jenkins\workspace\Test
[Pipeline] {
[Pipeline] unstash
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
[Pipeline] // node
[Pipeline] node
Running on blade in /opt/jenkins/root/workspace/Test
[Pipeline] {
[Pipeline] sh
[Test] Running shell script
+ rm -rf test.sh
[Pipeline] unstash
[Pipeline] sh
[Test] Running shell script
+ ls -l bin
total 8
-rw-r--r-- 1 jenkins users 4248 Aug 31 20:40 test
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESSSo, after unstashing the unix binary on windows node and stashing it back, it loses its unix file permissions.
Since windows does not have unix file permissions, I would expect that on windows would treat all files in 777 mode, especially after stashing back.
In case if you are wondering why is this important to me, here is the explanation:
I use Jenkins to build Conan packages of my software. The binaries are first built on various nodes for various platforms (windows, linux, macos, android and ios) and after binaries for every platform have been built successfully, they are all collected on first available node using the stash/unstash mechanism and there they are packaged and uploaded to Conan repository.
Due to this issue this causes for binaries that are built on unix nodes lose their file permissions if they are packaged on windows node. A possible workaround would be to enforce packaging on unix node or to perform some partial packaging on nodes that have created the binaries. As these workarounds work for me, I've set priority of this issue as "minor".
environment
```
Jenkins 2.140
Pipeline 2.5
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con la riproduzione fornita di Jenkins Pipeline che usa stash e unstash tra nodi macOS, Windows e Linux, quindi segui l’implementazione di questi passaggi in workflow-basic-steps-plugin. Verifica come vengono rappresentati i permessi dei file durante il passaggio di andata e ritorno attraverso Windows; il lavoro è completo quando i permessi di esecuzione Unix vengono preservati quando l’artefatto viene ripristinato su Linux con unstash.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- devops
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100