[英]Running go2xunit with a container on jenkins pipeline
I am trying to running tests on Jenkinspipeline within a container. 我正在尝试在容器内的Jenkinspipeline上运行测试。 where its unable to find one of the binaries
/bin/sh: line 2: go2xunit: command not found
找不到二进制文件
/bin/sh: line 2: go2xunit: command not found
Snippet of jenkins test stage : 詹金斯测试阶段的片段:
stage('Tests') {
steps {
// NOTE: you must include '|| :' so a failed test does not prevent the
// junit XML collection from running; any failed tests in the XML will
// mark the build as UNSTABLE and indicate failed tests in GHE and jenkins
sh 'make -f Makefile.release test'
junit 'test/*xml'
}
}
Makefile.release Makefile.release
.PHONY: test
test:
@docker run -it -v test:/src/test --rm ${BUILDER_TAG} \
2>&1 go test -v -short ./... | \
go2xunit -output test/test1.xml
Dockerfile Dockerfile
FROM golang:1.12.7-alpine AS builder
#Disable cgo
ENV CGO_ENABLED=0
WORKDIR /src
# Packages required for project build and test
RUN apk add --no-cache git make
RUN go get \
github.com/AlekSi/gocov-xml \
golang.org/x/lint/golint \
github.com/axw/gocov \
github.com/tebeka/go2xunit \
github.com/wadey/gocovmerge
# These layers are only re-built when Go modules are updated
COPY go.mod go.sum ./
RUN go mod download
# This layer is rebuilt when a file changes in the project directory
COPY . ./
RUN go install ./...
Where if I give the same commands on my local machine. 如果我在本地计算机上给出相同的命令,该在哪里。 Or if I run those commands from within the container it works well.
或者,如果我从容器中运行这些命令,则效果很好。
C02X37E2JG5J:push3 auser03$ docker run -it d919c2f58e74 /bin/sh
/src # make -f makefile.release test
What could I be missing here. 我在这里可能会错过什么。
You have to download go2x as direct dependency before running 'go2xunit' command. 在运行“ go2xunit”命令之前,您必须下载go2x作为直接依赖项。
go get github.com/tebeka/go2xunit
go test -v .\... | $(GOPATH)/bin/go2xunit -output test_report.xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.