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

Search





Overview

A BuildInfo resource is the metadata associated with a build in Artifactory.


JFrog Pipelines automatically creates BuildInfo when any of the Build steps like MvnBuild, NpmBuild, GradleBuild, or DockerBuild are used to generate packages.

BuildInfo is published to Artifactory:

Page Contents


YAML Schema

The YAML schema for BuildInfo:

resources:
  - name: 		<string>
    type: BuildInfo
    configuration:
      sourceArtifactory: 	artifactoryIntegration
      buildName: 			<string>
      buildNumber: 			<number>
      externalCI:           jenkinsIntegration 

Tags

name 

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

type 

Must be BuildInfo for this resource type.

configuration

Specifies all configuration selections for the resource.

Tag

Description

Required/Optional
sourceArtifactoryThe name of the Artifactory Integration.Required

buildName 

The name of the build to associate with this BuildInfo. Recommend using the environment variable available from the  step that generated the build.

Optional
buildNumber 

The number of the build to associate with this BuildInfo. Recommend using the environment variable available from the step that generated the build.

Optional
externalCIThe name of a linked Jenkins Integration.Optional

Environment Variables

Whenever Buildinfo is used in a step, a set of environment variables is automatically made available that can be used in your step.

Environment Variable

Description

res_<resource_name>_name
Name of the resource
res_<resource_name>_buildName
The name of the build associated with this BuildInfo.
res_<resource_name>_buildNumber
The number of the build associated with this BuildInfo.
res_<resource_name>_targetRepo
When set by PromoteBuild, the name of a repository in Artifactory for the BuildInfo.

Examples

Example 1

resources:
  - name: myGitRepo
    type: GitRepo
    configuration:
      gitProvider: my_github
      path: jfrog/jfrog-pipelines-simple-example
      branches:
        include: master
  - name: myBuildInfo
    type: BuildInfo
    configuration:
      sourceArtifactory: art
      buildName: SampleApp
      buildNumber: 1          
pipelines:  
  - name: basic_pipeline
    configuration:
      environmentVariables:
        readOnly:
          my_env_var: "hello"  
    steps:
      - name: step_1
        type: Bash
        configuration:
          inputResources:
            - name: myGitRepo
          outputResources:
            - name: myBuildInfo             
        execution:
          onExecute:
            - echo $my_env_var
            - if [ -z $app_version ]; then add_pipeline_variables app_version=1.0.0; else app_version=$(bump_semver $app_version minor); fi
            - write_output myBuildInfo "buildNumber=$app_version"
            - add_run_variables run_var="hello"
      - name: step_2
        type: Bash
        configuration:
          inputResources:
            - name: myBuildInfo            
          runtime:
            type: image
            image:
              auto:
                language: java
                versions: ['11']
        execution:
          onExecute:
            - echo $run_var  
            - echo $res_myBuildInfo_buildNumber
      - name: step_3
        type: Bash
        configuration:
          environmentVariables:
            step_env_var1: "hello"
          inputSteps:
            - name: step_2
        execution:
          onExecute:
            - echo $step_env_var1
      - name: step_4
        type: Bash
        configuration:
          inputSteps:
            - name: step_2
        execution:
          onExecute:
            - echo $app_version
      - name: step_5
        type: Bash
        configuration:
          inputSteps:
            - name: step_3
            - name: step_4  
          integrations:
            - name: my_github            
        execution:
          onExecute:
            - 'curl -H "Authorization: token ${int_my_github_token}" ${int_my_github_url}/rate_limit'

Example 2: When the BuildInfo resource is specified in the step's inputResources, then the update of that build information by the Jenkins build job will trigger the step.

resources:
  - name: jenkinsBuildInfo
    type: BuildInfo
    configuration:
      sourceArtifactory: myArtifactory		# Replace with your Artifactory integration name
      buildName: sample-build				# Replace with your build name
      buildNumber: 1
      externalCI: MyJenkins					# Replace with your Jenkins integration name

pipelines:
  - name: pipelines_trigger
    steps:
      - name: start_from_jenkins
        type: Bash
        configuration:
          inputResources:
            - name: jenkinsBuildInfo
        execution:
          onExecute:
            - echo 'Jenkins job triggered Pipelines' 
  • No labels
Copyright © 2021 JFrog Ltd.