drnf593779 2019-07-26 20:57
浏览 120

在jenkins管道上使用容器运行go2xunit

I am trying to running tests on Jenkinspipeline within a container. where its unable to find one of the binaries /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

.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

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.

  • 写回答

1条回答 默认 最新

  • duanji5746 2019-08-23 13:33
    关注

    You have to download go2x as direct dependency before running 'go2xunit' command.

    go get github.com/tebeka/go2xunit
    go test -v .\... | $(GOPATH)/bin/go2xunit -output test_report.xml
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误