Fix ECR & GCR docker publish on windows (#352)
This commit is contained in:
parent
0ffe085ddc
commit
47dc8555ad
@ -7,6 +7,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
docker "github.com/drone-plugins/drone-docker"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -40,12 +43,12 @@ func main() {
|
||||
os.Setenv("DOCKER_PASSWORD", password)
|
||||
|
||||
// invoke the base docker plugin binary
|
||||
cmd := exec.Command("drone-docker")
|
||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -327,3 +328,11 @@ func run(c *cli.Context) error {
|
||||
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
func GetExecCmd() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "C:/bin/drone-docker.exe"
|
||||
}
|
||||
|
||||
return "drone-docker"
|
||||
}
|
||||
|
@ -11,12 +11,15 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/ecr"
|
||||
|
||||
docker "github.com/drone-plugins/drone-docker"
|
||||
)
|
||||
|
||||
const defaultRegion = "us-east-1"
|
||||
@ -110,11 +113,11 @@ func main() {
|
||||
os.Setenv("DOCKER_PASSWORD", password)
|
||||
|
||||
// invoke the base docker plugin binary
|
||||
cmd := exec.Command("drone-docker")
|
||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err = cmd.Run(); err != nil {
|
||||
os.Exit(1)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
docker "github.com/drone-plugins/drone-docker"
|
||||
)
|
||||
|
||||
// gcr default username
|
||||
@ -54,12 +57,12 @@ func main() {
|
||||
os.Setenv("DOCKER_PASSWORD", password)
|
||||
|
||||
// invoke the base docker plugin binary
|
||||
cmd := exec.Command("drone-docker")
|
||||
cmd := exec.Command(docker.GetDroneDockerExecCmd())
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -416,3 +417,11 @@ func commandRmi(tag string) *exec.Cmd {
|
||||
func trace(cmd *exec.Cmd) {
|
||||
fmt.Fprintf(os.Stdout, "+ %s\n", strings.Join(cmd.Args, " "))
|
||||
}
|
||||
|
||||
func GetDroneDockerExecCmd() string {
|
||||
if runtime.GOOS == "windows" {
|
||||
return "C:/bin/drone-docker.exe"
|
||||
}
|
||||
|
||||
return "drone-docker"
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ echo $env:VERSION
|
||||
echo $env:REGISTRY
|
||||
|
||||
# build the binary
|
||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe";
|
||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}";
|
||||
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
||||
|
||||
# build and publish the docker image
|
||||
|
@ -30,7 +30,7 @@ echo $env:GOARCH
|
||||
echo $env:VERSION
|
||||
|
||||
# build the binary
|
||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe"
|
||||
Write-Host "+ go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}"
|
||||
go build -o release/windows/amd64/drone-${env:REGISTRY}.exe ./cmd/drone-${env:REGISTRY}
|
||||
|
||||
# authenticate with the docker registry
|
||||
|
Loading…
Reference in New Issue
Block a user