Run your jenkins pipeline with openiated .ci-pipeline.yaml (instead of the generic Jenkinsfile).
-
Place the file
.ci-pipeline.yamlin the root dir of your project see example here see next section on an example of the file.
image: golang:alpine
variables:
TEST_URL: http://example.com
POSTGRES_PASSWORD: t@st!p@ssw0rd
services:
- postgres:latest
- nginx:latest
- redis:alpine
- docker
steps:
- name: build
actions:
- echo "building step 1" && go version
- echo "building step 2"
- parallel:
- name: unit test
except:
- master
actions:
- echo "unit testing against test url $TEST_URL and referring to builtin var $NODE_NAME"
- name: integration test
only: [develop, release/*]
actions:
- apk add curl && apk add redis
- echo "testing nginx" && curl nginx:80
- echo "testing redis" && echo INCR x | redis-cli -h redis
- name: deploy
trigger: manual
only:
- release/*
actions:
- echo "do deploy"
- docker version
The image that will be used to run your build process.
you can choose whatever image you want, it need to have the compiler toolchain commands preinstall so to run the build scripts you the steps section below.
The timeout in minutes for each pipeline, default is 10 .
Variables to be injected in build environment as well as being passed to any running service (see services section below)
A list of docker images to be run while the build process is running. typically it might be a database or cache serivce.
You can pass variables to the image by using the variables section above. for example you can define the default username or password for the database in as a variable in the variables section above.
Note: If you need the
dockercommand available in your pipeline, for example you need to build and image for your app and push it to the registry, then includedockeras service in this section (see example above).
This is the section where you write your actual build scripts.
Note: The steps runs in parallel by nesting the steps inside
parallel(see example above).
Each step consist of the following:
Name of the step (required)
The branch list what the step will run on (optional). uses ant glob pattern.
The branch list what the step will not run on (optional). uses ant glob pattern.
Whether to trigger the job manual or automatic, the default is automatic
Here is the actual scripts your write to do the build/test/deploy etc. for examle you can do mvn clean package or go build or npm install or whatever.
This project is inspired by wolox-ci