1 回答
TA贡献2011条经验 获得超2个赞
我想到了。
Jenkinsfile以下是我位于项目目录根目录中的内容:
#!/usr/bin/env groovy
// The above line is used to trigger correct syntax highlighting.
pipeline {
agent { docker { image 'golang' } }
stages {
stage('Build') {
steps {
// Create our project directory.
sh 'cd ${GOPATH}/src'
sh 'mkdir -p ${GOPATH}/src/YOUR_PROJECT_DIRECTORY'
// Copy all files in our Jenkins workspace to our project directory.
sh 'cp -r ${WORKSPACE}/* ${GOPATH}/src/YOUR_PROJECT_DIRECTORY'
// Copy all files in our "vendor" folder to our "src" folder.
sh 'cp -r ${WORKSPACE}/vendor/* ${GOPATH}/src'
// Remove build cache.
sh 'go clean -cache'
// Build the app.
sh 'go build'
}
}
// Each "sh" line (shell command) is a step,
// so if anything fails, the pipeline stops.
stage('Test') {
steps {
// Remove cached test results.
sh 'go clean -testcache'
// Run all Tests.
sh 'go test ./... -v'
}
}
}
}
- 1 回答
- 0 关注
- 131 浏览
添加回答
举报