Skip to content

edgeXBuildGoApp

Shared Library to build Go projects

Overview

edgeXBuildGoApp

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.21
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
dockerFilePath optional str The path to the Dockerfile for your project.

Default: Dockerfile
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
dockerBuildArgs optional list The list of additonal arguments to pass to Docker when building the image for your project.

Default: []
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: ''
dockerImageName optional str The name of the Docker image for your project.

Default: docker-${project}
dockerNexusRepo optional str The name of the Docker Nexus repository where the project Docker image dockerImageName 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 false.

Default: 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
semverVersion optional str This parameter isn't currently used and will be removed in a future version.

Default: ''
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']
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
buildExperimentalDockerImage optional bool Specify if Jenkins should add an additonal GitHub tag called experimental at the same commit where the semantic version is tagged. Note this feature is currently only used internally for DevOps builds.

Default: false
artifactTypes optional list A list of types that the Jenkins build will designate as artifacts, valid list values are docker and archive. Note if archive is specified then all tar.gz or zip files that your project build creates in the artifactRoot folder will be archived to Nexus.

Default: ['docker']
artifactRoot optional str The path in the Jenkins workspace to designate as the artifact root folder. Note all files written to this directory within your build will be automatically pushed to Nexus when the Jenkins job completes.

Default: archives/bin
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

edgeXBuildGoApp (
    project: 'device-random-go',
    goVersion: '1.16'
)

Complex example

edgeXBuildGoApp (
    project: 'app-functions-sdk-go',
    semver: true,
    goVersion: '1.16',
    testScript: 'make test',
    buildImage: false,
    publishSwaggerDocs: true,
    swaggerApiFolders: ['openapi/v2']
)

Full example

This example shows all the settings that can be specified and their default values.

edgeXBuildGoApp (
    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,
    dockerFilePath: 'Dockerfile',
    dockerBuildFilePath: 'Dockerfile.build',
    dockerBuildContext: '.',
    dockerBuildArgs: [],
    dockerNamespace: '',
    dockerImageName: 'docker-go-project',
    dockerNexusRepo: 'staging',
    buildImage: true,
    pushImage: true,
    semverBump: 'pre',
    buildSnap: false,
    publishSwaggerDocs: false,
    swaggerApiFolders: ['openapi/v1'],
    failureNotify: 'edgex-tsc-core@lists.edgexfoundry.org,edgex-tsc-devops@lists.edgexfoundry.org',
    buildExperimentalDockerImage: false,
    artifactTypes: ['docker'],
    artifactRoot: 'archives/bin',
    arch: ['amd64', 'arm64']

)