GoBuild - Examples

JFrog Pipelines Documentation

Products
JFrog Pipelines
Content Type
User Guide
ft:sourceType
Paligo

The following examples show how to configure a GoBuild step. For more information on GoBuild Pipeline steps, see GoBuild.

Full Pipeline Example

# This config file is templatized so that it can be easily customized. Values can be provided with a values.yml file. For more information, see the 'Pipeline Example: Go Build' quickstart.
template: true   # required for local templates
valuesFilePath: ./values.yml

resources:
  # Sample Go app in a GitRepo
  - name: go_repo
    type: GitRepo
    configuration:
      path: {{ .Values.repoPath }}
      branches:
        include: main
      gitProvider: {{ .Values.gitProvider }}

  # Build info for the published Go app
  - name: go_buildinfo
    type: BuildInfo
    configuration:
      sourceArtifactory: {{ .Values.artifactory }}


pipelines:
  - name: go_build_pipeline_example
    steps:
      # Build the Go sample app from the GitRepo
      - name: build_go
        type: GoBuild
        configuration:
          sourceLocation: .
          resolverRepo: go-virtual
          noRegistry: true
          inputResources:
            - name: go_repo
          integrations:
            - name: {{ .Values.artifactory }}

              # Publish the Go sample app binary to Artifactory
      - name: publish_go_binary
        type: GoPublishBinary
        configuration:
          inputSteps:
            - name: build_go
          targetRepository: go-local
          integrations:
            - name: {{ .Values.artifactory }}

      # Publish the Go sample app build info
      - name: publish_build
        type: PublishBuildInfo
        configuration:
          inputSteps:
            - name: publish_go_binary
          outputResources:
            - name: go_buildinfo

Default Locations

A GoBuild step using default locations.

GoBuild

pipelines: 
  - name: goBuildPipeline
    steps:
      - name: goBuildStep
        type: GoBuild
        configuration: 
          inputResources:
            - name: gitRepoResource
          integrations:
            - name: artifactory_integration

FileSpec Input

A GoBuild step with a FileSpec input providing files for the build that are not in the GitRepo and resolverRepo specifying an Artifactory repository to use when resolving dependencies.

GoBuild

pipelines: 
  - name: goBuildPipeline
    steps:
      - name: goBuildStep
        type: GoBuild
        configuration:
          resolverRepo: repo
          inputResources:
            - name: gitRepoResource
            - name: fileSpec

Alternative Source Location in Git Repo

A GoBuild step with an alternative source location in the GitRepo and an alternative Go command for the build.

GoBuild

pipelines: 
  - name: goBuildPipeline
    steps:
      - name: goBuildStep
        type: GoBuild
        configuration: 
          sourceLocation: "app/go"
          goCommand: "build -insecure -o output/outputFile"
          inputResources:
            - name: gitRepoResource
          integrations:
            - name: artifactory_integration