我正在从GitLab CI迁移到Woodpecker CI。目前的管道定义为:
default:
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- $CI_PROJECT_DIR/.m2/repository/
image: docker.io/library/eclipse-temurin:8-jdk-focal
stages:
- compile
variables:
MAVEN_CONFIG: --batch-mode --no-transfer-progress
MAVEN_OPTS: -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository/
compile:
stage: compile
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
script:
- ./mvnw compile $MAVEN_EXTRA_OPTS
variables:
MAVEN_EXTRA_OPTS: -DskipTests=true我试图找到一种方法来声明MAVEN_CONFIG和MAVEN_OPTS,就像它们在GitLab CI中公开的方式一样(阅读:针对所有步骤),但到目前为止,我还没有找到解决方案。我基本上是在接下来的步骤中再次声明它们。
这个功能可用吗?我错过了它,还是还没有实现呢?
发布于 2022-05-24 16:02:16
您需要创建一个.woodpecker.yml文件,用步骤定义管道。瞧,啄木鸟CI:简介。
# .woodpecker.yml
pipeline:
build:
image: debian
commands:
- echo "This is the build step"
a-test-step:
image: debian
commands:
- echo "Testing.."若要设置环境变量,请使用environment键。瞧,啄木鸟CI:环境变量。
pipeline:
build:
image: golang
environment:
# set environment variables
- CGO=0
- GOOS=linux
- GOARCH=amd64
commands:
# expand/resolve environment variables by exporting
- export PATH=$PATH:/go
- go build
- go test可以通过WOODPECKER_ENVIRONMENT变量为所有构建全局设置环境变量。瞧,啄木鸟CI:全球环境变化。
您应该能够使用yaml锚和别名在步骤之间共享命令,就像在这个例子中一样。
.set-maven-env-vars: &set-maven-env-vars
- export MAVEN_CONFIG="--batch-mode --no-transfer-progress"
- export MAVEN_OPTS="-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository/"
pipeline:
build:
image: golang
commands:
- *set-maven-env-vars
- go build
- go testhttps://stackoverflow.com/questions/72364430
复制相似问题