Guidance for Go Projects

Jenkinsfile

Currently, the default build image for projects is ckm/map-maven-java-image-jdk17, which contains the necessary tools to build most project types, however it does not include Go and Go-related tools that are needed for these projects to succeed.

To configure your project to use the Go build image instead, change the buildServiceProject() call in Jenkinsfile to:

buildServiceProject(mavenImage: 'ckm/map-maven-go-image:1.4.0-64648dbe001840238c9bb88b7bb3ee18d7fd1258')

Then, in the pom.xml of the Go service module directory, add the following user property override:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!-- snip -->
    <properties>
        <skipJenkinsfile>true</skipJenkinsfile>

This will prevent the Jenkinsfile from being overwritten from the latest version of the template on each build.

Dependencies

For the Dependabot scan to work with a Go project, additional configuration is required to point this tool to the dependency file (go.mod) used for the project.

Add the following content to the .github/dependabot.yml file in the project root directory:

version: 2
updates:
- package-ecosystem: "gomod" (1)
  directory: "<dir-of-go-service>" (2)
1 gomod indicates the go.mod Go project dependency file
2 Replace <dir-of-go-service> with the project-root-relative subdirectory/module of the Go project to be scanned
Internal Dependency Bug

As of 2/16/2024, there are issues with the Dependabot OIS scan of Go projects that have dependencies on NGSS-internal Go projects (dependencies that are specified in the go.mod file).

To test the inclusion of the Jenkins Shared Library in affected projects, temporarily disable OIS scanning by adding the following to the project’s jenkins.yaml:

enableOisScan: false

Once this issue is fixed, OIS scans should be re-enabled. Monitor this page for updates.