github.com/jaylevin/jenkins-library@v1.230.4/cmd/transportRequestDocIDFromGit.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/SAP/jenkins-library/pkg/log"
     5  	"github.com/SAP/jenkins-library/pkg/telemetry"
     6  )
     7  
     8  func transportRequestDocIDFromGit(config transportRequestDocIDFromGitOptions,
     9  	telemetryData *telemetry.CustomData,
    10  	commonPipelineEnvironment *transportRequestDocIDFromGitCommonPipelineEnvironment) {
    11  
    12  	err := runTransportRequestDocIDFromGit(&config, telemetryData, &gitIDInRange{}, commonPipelineEnvironment)
    13  	if err != nil {
    14  		log.Entry().WithError(err).Fatal("step execution failed")
    15  	}
    16  }
    17  
    18  func runTransportRequestDocIDFromGit(config *transportRequestDocIDFromGitOptions,
    19  	telemetryData *telemetry.CustomData,
    20  	trUtils gitIDInRangeFinder,
    21  	commonPipelineEnvironment *transportRequestDocIDFromGitCommonPipelineEnvironment) error {
    22  
    23  	cdID, err := getChangeDocumentID(config, trUtils)
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	commonPipelineEnvironment.custom.changeDocumentID = cdID
    29  
    30  	log.Entry().Infof("Retrieved change document ID '%s' from Git.", cdID)
    31  
    32  	return nil
    33  }
    34  
    35  func getChangeDocumentID(config *transportRequestDocIDFromGitOptions,
    36  	trUtils gitIDInRangeFinder) (string, error) {
    37  
    38  	return trUtils.FindIDInRange(config.ChangeDocumentLabel, config.GitFrom, config.GitTo)
    39  }