Cloud customer?
Start for Free >
Upgrade in MyJFrog >
What's New in Cloud >

Search





Overview

The GoPublishBinary native step publishes the GO (GoLang) binaries built in a GoBuild step to Artifactory. 


Page Contents


YAML Schema

The YAML schema for GoPublishBinary native step is as follows:

GoPublishBinary
pipelines: 
  - name:   <string>
    steps:
      - name: <string>
        type: GoPublishBinary
        configuration:
          #inherits all the tags from bash; https://www.jfrog.com/confluence/display/JFROG/Bash

          forceXrayScan:   		<boolean>  # optional
          failOnScan:           <boolean>  # default true
          autoPublishBuildInfo: <boolean>  # optional
          targetRepository:     <string>   # required
		  failOnValidate:       <boolean>  # optional (Signed Pipelines must be enabled)

          integrations:
            - name:         <artifactory integration>  # required if autoPublishBuildInfo is false
          outputResources:
            - name:         <BuildInfo resource>       # required if autoPublishBuildInfo is true
          inputSteps:
            - name:         <GoBuild, Bash, or PowerShell step> # required

        execution:
          onStart:
            - echo "Preparing for work..."
          onSuccess:
            - echo "Job well done!"
          onFailure:
            - echo "uh oh, something went wrong"
          onComplete:                                  #always
            - echo "Cleaning up some stuff"

Tags

name 

An alphanumeric string (underscores are permitted) that identifies the step.

type 

Must be GoPublishBinary for this step type.

configuration

Specifies all configuration selections for the step's execution environment. This step inherits the Bash/PowerShell step configuration tags, including these pertinent tags:

Tag

Description of usage

Required/Optional
integrations  

Specifies an Artifactory Integration. Required when autoPublishBuildInfo is set to false. Otherwise, the artifactory integration specified in the BuildInfo resource will be used.

May be required
outputResources  

Must specify a BuildInfo resource when autoPublishBuildInfo is set to true. 

If JFROG_CLI_BUILD_NAME or JFROG_CLI_BUILD_NUMBER is set as an environment variable for the pipeline or the input GoBuild step, that name and/or number is used for the output BuildInfo. Otherwise, the default buildName and buildNumber are $pipeline_name and $run_number respectively.

May be required
inputSteps Must specify a GoBuildBash, or PowerShell step.Required


In addition, these tags can be defined to support the step's native operation:

Tags derived from Bash

All native steps derive from the Bash step. This means that all steps share the same base set of tags from Bash, while native steps have their own additional tags as well that support the step's particular function. So it's important to be familiar with the Bash step definition, since it's the core of the definition of all other steps.

Tag

Description of usage

Required/Optional
forceXrayScan

When true, forces a scan of the pushed image by JFrog Xray.

Default is false.

Optional
failOnScan

When set to t rue, and when the Xray Policy Rule Fail Build checkbox is checked, a failed Xray scan will result in a failure of the step.

Default is true.

Optional
autoPublishBuildInfo

When set to true, publishes build info with the Docker image.

Default is false.

Optional
targetRepositoryRepository in Artifactory where the module will be published.Required
failOnValidate

Fail the step if signatures of build artifacts cannot be verified.

Default is false.

Optional (Signed Pipelines must be enabled)


execution

Declares collections of shell command sequences to perform for pre- and post-execution phases:
TagDescription of usageRequired/Optional
onStartCommands to execute in advance of the native operationOptional
onSuccessCommands to execute on successful completionOptional
onFailureCommands to execute on failed completionOptional
onCompleteCommands to execute on any completionOptional


The actions performed for the onExecute phase are inherent to this step type and may not be overridden.


Examples

The following examples show how to configure a GoPublishBinary step.

Upload to Artifactory

Uploads the binary built by a GoBuild step to an Artifactory repository named go-local.

# 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. Docs at https://www.jfrog.com/confluence/display/JFROG/GoBuild
      - 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. Docs at https://www.jfrog.com/confluence/display/JFROG/GoPublishBinary
      - name: publish_go_binary
        type: GoPublishBinary
        configuration:
          inputSteps:
            - name: build_go
          targetRepository: go-local
          integrations:
            - name: {{ .Values.artifactory }}

Upload Build Info

Uploads the binary built by a GoBuild step to an Artifactory repository named go-repo and uploads build info. This extends example 1 in the GoBuild documentation.

GoPublishBinary
pipelines: 
  - name: goBuildPipeline
    steps:
      - name: goBuildStep
        type: GoBuild
        configuration:
          inputResources:
            - name: gitRepoResource
          integrations:
            - name: artifactory_integration
      - name: goPublishBinaryStep
        type: GoPublishBinary
        configuration:
          targetRepository: go-repo
          autoPublishBuildInfo: true
          inputSteps:
            - name: goBuildStep
          outputResources:
            - name: outputBuildInfo

Publish Build Info and Trigger Xray Scan

In this example, build info is published and an Xray scan triggered.

GoPublishBinary
pipelines: 
  - name: goBuildPipeline
    steps:
      - name: goBuildStep
        type: GoBuild
        configuration:
          inputResources:
            - name: gitRepoResource
          integrations:
            - name: artifactory_integration
      - name: goPublishBinaryStep
        type: GoPublishBinary
        configuration:
          targetRepository: go-repo
          autoPublishBuildInfo: true
          forceXrayScan: true
          inputSteps:
            - name: goBuildStep
          outputResources:
            - name: outputBuildInfo

How it Works

When you use the GoPublishBinary native step in a pipeline, it performs the following functions in the background:

  • jfrog rt config (if there is a BuildInfo output, configure the JFrog CLI with those credentials)
  • jfrog rt use (specify the configured credentials to use)
  • restore_run_files (copy the output and build info from the GoBuild step)
  • jfrog rt upload (upload the binary)
  • jfrog rt build-publish (if autoPublishBuildInfo is true, publish the build info)
  • write_output (if autoPublishBuildInfo is true, update the output BuildInfo resource)
  • jfrog rt build-scan (if forceXrayScan is true, trigger a scan)
  • add_run_files (update the build info saved in run state)

Related Topics

Go Build Quickstart

  • No labels
Copyright © 2021 JFrog Ltd.