edgeXBuildGoParallel
Shared Library to build Go projects and Docker images in parallel. Utilizes docker compose --parallel to build Docker images found in the workspace. Currently only used for the edgex-go mono-repo.
Overview
Parameters
Name | Required | Type | Description and Default Value |
---|---|---|---|
project | required | str | The name of your project. |
mavenSettings | optional | str | The maven settings file in Jenkins that has been created for your project. Note the maven settings file specified must exist in Jenkins in order for your project to build. Default: ${project}-settings |
semver | optional | bool | Specify if semantic versioning will be used to version your project. Note edgeX utilizes git-semver for semantic versioning. Default: true |
testScript | optional | str | The command the build will use to test your project. Note the specified test script will execute in the project's CI build container. Default: make test |
buildScript | optional | str | The command the build will use to build your project. Default: make build |
goVersion | optional | str | The version of Go to use for building the project's CI build image. Note this parameter is used in conjuction with the useAlpineBase parameter to determine the base for the project's CI build image.Default: 1.23 |
goProxy | optional | str | The proxy to use when downloading Go modules. The value of this parameter will be set in the GOPROXY environment variable to control the download source of Go modules.Default: https://nexus3.edgexfoundry.org/repository/go-proxy/ |
useAlpineBase | optional | bool | Specify if an Alpine-based edgex-golang-base:${goVersion}-alpine image will be used as the base for the project's CI build image. If true, the respective edgex-golang-base image should exist in the Nexus snapshot repository, if a matching image is not found in Nexus then an Alpine-based go-lang:${goVersion}-alpine DockerHub image will be used. If false, then a non-Alpine go-lang:${goVersion} DockerHub image will be used. Note this parameter is used in conjuction with the goVersion parameter to determine the base for the projects' CI build image.Default: true |
dockerFileGlobPath | optional | str | The pattern for finding Dockerfiles to build. Note Docker images will be named with the same name as the directory which the Dockerfile was found in with a docker- prefix and -go suffix. Example: docker-<folder>-go Default: cmd/** /Dockerfile |
dockerImageNamePrefix | optional | str | The prefix to apply to the names of all the Docker images built. Default: docker- |
dockerImageNameSuffix | optional | str | The suffix to apply to the names of all the Docker images built. Default: -go |
dockerBuildFilePath | optional | str | The path to the Dockerfile that will serve as the CI build image for your project. Default: Dockerfile.build |
dockerBuildContext | optional | str | The path for Docker to use as its build context when building your project. This applies to building both the CI build image and project image. Default: . |
dockerBuildImageTarget | optional | str | The name of the docker multi-stage-build stage the pipeline will use when building the CI build image. Default: builder |
dockerNamespace | optional | str | The docker registry namespace to use when publishing Docker images. Note for EdgeX projects images are published to the root of the docker registry and thus the namespace should be empty. Default: '' |
dockerNexusRepo | optional | str | The name of the Docker Nexus repository where the project Docker images will be published to if pushImage is set.Default: staging |
buildImage | optional | bool | Specify if Jenkins should build a Docker image for your project. Note if false then pushImage will also be set to falseDefault: true |
pushImage | optional | bool | Specify if Jenkins should push your project's image to dockerNexusRepo .Default: true |
semverBump | optional | str | The semver axis to bump, see git-semver for valid axis values. Default: pre |
buildSnap | optional | bool | Specify if Jenkins should build a Snap for your project. Note If set, your project must also include a valid snapcraft yaml snap/snapcraft.yaml for Jenkins to attempt to build the Snap.Default: false |
publishSwaggerDocs | optional | bool | Specify if Jenkins should attempt to publish your projects API documentation to SwaggerHub. Note in order for Jenkins to publish to SwaggerHub you must ensure a valid value for swaggerApiFolders is set.Default: false |
swaggerApiFolders | optional | list | The list of paths to your projects API Swagger-based documentation. Default: ['openapi/v1', 'openapi/v2'] |
failureNotify | optional | str | The group emails (comma-delimited) to email when the Jenkins job fails. Default: edgex-tsc-core@lists.edgexfoundry.org,edgex-tsc-devops@lists.edgexfoundry.org |
arch | optional | array | A list of system architectures to target for the build. Possible values are amd64 or arm64 .Default: ['amd64', 'arm64'] |
Usage
Basic example
edgeXBuildGoParallel (
project: 'edgex-go',
dockerFileGlobPath: 'cmd/** /Dockerfile',
)
Complex example
edgeXBuildGoParallel(
project: 'edgex-go',
dockerFileGlobPath: 'cmd/** /Dockerfile',
testScript: 'make test',
buildScript: 'make build',
publishSwaggerDocs: true,
swaggerApiFolders: ['openapi/v1', 'openapi/v2'],
buildSnap: true
)
Full example
This example shows all the settings that can be specified and their default values.
edgeXBuildGoParallel (
project: 'go-project',
mavenSettings: 'go-project-settings',
semver: true,
testScript: 'make test',
buildScript: 'make build',
goVersion: '1.16',
goProxy: 'https://nexus3.edgexfoundry.org/repository/go-proxy/',
useAlpineBase: true,
dockerFileGlobPath: 'cmd/** /Dockerfile',
dockerImageNamePrefix: 'docker-',
dockerImageNameSuffix: '-go',
dockerBuildFilePath: 'Dockerfile.build',
dockerBuildContext: '.',
dockerNamespace: '',
dockerNexusRepo: 'staging',
buildImage: true,
pushImage: true,
semverBump: 'pre',
buildSnap: false,
publishSwaggerDocs: false,
swaggerApiFolders: ['openapi/v1', 'openapi/v2'],
failureNotify: 'edgex-tsc-core@lists.edgexfoundry.org,edgex-tsc-devops@lists.edgexfoundry.org',
arch: ['amd64', 'arm64']
)