Build and upload Swagger Codegen CLI Docker image on release (#4912)

* Run mvn in batch-mode to be less verbose on download

* Build and upload Swagger Codegen CLI Docker image on release

* Ensure we only push master and tags to Docker Hub
This commit is contained in:
Arne Jørgensen 2017-03-12 10:09:47 +01:00 committed by wing328
parent c76f006067
commit 0b9aaad1c2
2 changed files with 8 additions and 6 deletions

View File

@ -62,9 +62,11 @@ script:
# fail if generators contain tab '\t'
- /bin/bash ./bin/utils/detect_tab_in_java_class.sh
# run integration tests defined in maven pom.xml
- mvn verify -Psamples
# docker test
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG; fi && docker push $DOCKER_IMAGE_NAME; fi
- mvn --batch-mode verify -Psamples
# docker: build generator image and push to Docker Hub
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi
# docker: build cli image and push to Docker Hub
- if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi
env:
- DOCKER_IMAGE_NAME=swaggerapi/swagger-generator
- DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli

View File

@ -191,7 +191,7 @@ docker stop $CID && docker rm $CID
In the example above, `result.zip` will contain the generated client.
##### Swagger Codegen Docker Image
##### Swagger Codegen CLI Docker Image
The Swagger Codegen image acts as a standalone executable. It can be used as an alternative to installing via homebrew, or for developers who are unable to install Java or upgrade the installed version.
@ -200,7 +200,7 @@ To generate code with this image, you'll need to mount a local location as a vol
Example:
```
docker run --rm -v ${PWD}:/local swagger-api/swagger-codegen generate \
docker run --rm -v ${PWD}:/local swagger-api/swagger-codegen-cli generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l go \
-o /local/out/go