我的Drone配置发生了问题。从今天开始就没有找到环境变量。直到几天前,我还可以运行管道,但今天不能。
这是进入管道的步骤:
pipeline: [...] sdk: image: mycompany/swagger-codegen:latest environment: - API_SWAGGER_JSON_URL=http://api.mycompany.biz:9000/v1/swagger.json - API_PACKAGE=com.mycompany.api - API_GROUP_ID=com.mycompany.api - API_ARTIFACT_ID=sdk - API_VERSION=0.1-SNAPSHOT when: branch: master commands: - java -jar /usr/lib/swagger/swagger-codegen-cli.jar generate -i ${API_SWAGGER_JSON_URL} --api-package ${API_PACKAGE} --invoker-package ${API_PACKAGE}.client --model-package ${API_PACKAGE}.client.model --group-id ${API_GROUP_ID} --artifact-id ${API_ARTIFACT_ID} --artifact-version ${API_VERSION} -l java -o ./swagger-codegen-source - etc.
这就是我得到的
+ java -jar /usr/lib/swagger/swagger-codegen-cli.jar generate -i --api-package --invoker-package .client --model-package .client.model --group-id --artifact-id --artifact-version -l java -o ./swagger-codegen-source Exception in thread "main" io.airlift.airline.ParseArgumentsUnexpectedException: Found unexpected parameters: [java] at io.airlift.airline.Cli.validate(Cli.java:148) at io.airlift.airline.Cli.parse(Cli.java:116) at io.airlift.airline.Cli.parse(Cli.java:97) at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:36)
看一下命令。每个环境变量都替换为一个空字符串。难道我做错了什么?
您应该使用$variable
或$${variable}
代替${variable}
这是因为无人机使用${variable}
语法将运行时变量[1]插值到yaml中。此行为类似于docker-compose,后者将无人机用作功能和语法的基准。
[1] http://docs.drone.io/environment/
[2] http://docs.drone.io/secrets-not-working/#variable-expansion