@@ -13,7 +13,6 @@ import (
13
13
"path"
14
14
"path/filepath"
15
15
"regexp"
16
- "strconv"
17
16
"strings"
18
17
"sync"
19
18
@@ -404,60 +403,9 @@ func (b *Builder) BuildStep(step *Step, step_number int) error {
404
403
}
405
404
406
405
if len (step .Artifacts ) > 0 {
407
- b .Conf .Logger .Noticef ("Starting container %s to fetch artifact permissions" , container .ID )
408
- startOpts := & docker.HostConfig {}
409
- err := b .docker .StartContainer (container .ID , startOpts )
410
- if err != nil {
411
- return err
412
- }
413
-
414
- permMap := make (map [string ]int )
415
-
416
- for _ , art := range step .Artifacts {
417
- execOpts := docker.CreateExecOptions {
418
- Container : container .ID ,
419
- AttachStdin : false ,
420
- AttachStdout : true ,
421
- AttachStderr : true ,
422
- Tty : false ,
423
- Cmd : []string {"stat" , "--format='%a'" , art .Source },
424
- }
425
- execObj , err := b .docker .CreateExec (execOpts )
426
- if err != nil {
427
- return err
428
- }
429
-
430
- buf := new (bytes.Buffer )
431
- startExecOpts := docker.StartExecOptions {
432
- OutputStream : buf ,
433
- ErrorStream : os .Stderr ,
434
- RawTerminal : false ,
435
- Detach : false ,
436
- }
437
-
438
- if err := b .docker .StartExec (execObj .ID , startExecOpts ); err != nil {
439
- b .Conf .Logger .Errorf ("Failed to fetch artifact permissions for %s: %s" , art .Source , err .Error ())
440
- }
441
-
442
- permsString := strings .Replace (strings .Replace (buf .String (), "'" , "" , - 1 ), "\n " , "" , - 1 )
443
- perms , err := strconv .Atoi (permsString )
444
- if err != nil {
445
- b .Conf .Logger .Errorf ("Failed to fetch artifact permissions for %s: %s" , art .Source , err .Error ())
446
- }
447
- permMap [art .Source ] = perms
448
- b .Conf .Logger .Debugf ("Permissions for %s is %d" , art .Source , perms )
449
- }
450
-
451
- b .Conf .Logger .Debugf ("Stopping the container %s" , container .ID )
452
- err = b .docker .StopContainer (container .ID , 0 )
453
- if err != nil {
454
- return err
455
- }
456
-
457
406
b .Conf .Logger .Noticef ("Copying artifacts from %s" , container .ID )
458
-
459
407
for _ , art := range step .Artifacts {
460
- err = b .copyToHost (& art , container .ID , permMap )
408
+ err = b .copyToHost (& art , container .ID )
461
409
if err != nil {
462
410
return err
463
411
}
@@ -595,18 +543,7 @@ func (b *Builder) replaceFromField(step *Step, step_number int) error {
595
543
return nil
596
544
}
597
545
598
- func overwrite (mpath string ) (* os.File , error ) {
599
- f , err := os .OpenFile (mpath , os .O_RDWR | os .O_TRUNC , 0777 )
600
- if err != nil {
601
- f , err = os .Create (mpath )
602
- if err != nil {
603
- return f , err
604
- }
605
- }
606
- return f , nil
607
- }
608
-
609
- func (b * Builder ) copyToHost (a * Artifact , container string , perms map [string ]int ) error {
546
+ func (b * Builder ) copyToHost (a * Artifact , container string ) error {
610
547
// create the artifacts distination folder if not there
611
548
destPath := path .Join (b .Conf .Workdir , a .Dest )
612
549
err := os .MkdirAll (destPath , 0777 )
@@ -658,15 +595,7 @@ func (b *Builder) copyToHost(a *Artifact, container string, perms map[string]int
658
595
default :
659
596
return errors .New ("Invalid header type" )
660
597
}
661
-
662
- b .Conf .Logger .Debugf ("Setting file permissions for %s to %d" , destFile , perms [a .Source ])
663
- err = os .Chmod (destFile , os .FileMode (perms [a .Source ])| 0700 )
664
- if err != nil {
665
- return err
666
- }
667
-
668
598
}
669
-
670
599
return nil
671
600
}
672
601
0 commit comments