github.com/jfrog/jfrog-cli-core/v2@v2.52.0/pipelines/commands/trigger.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/jfrog/jfrog-cli-core/v2/pipelines/manager"
     5  	"github.com/jfrog/jfrog-cli-core/v2/utils/config"
     6  )
     7  
     8  type TriggerCommand struct {
     9  	serverDetails *config.ServerDetails
    10  	branch        string
    11  	pipelineName  string
    12  	isMultiBranch bool
    13  }
    14  
    15  func NewTriggerCommand() *TriggerCommand {
    16  	return &TriggerCommand{}
    17  }
    18  
    19  func (tc *TriggerCommand) ServerDetails() (*config.ServerDetails, error) {
    20  	return tc.serverDetails, nil
    21  }
    22  
    23  func (tc *TriggerCommand) SetServerDetails(serverDetails *config.ServerDetails) *TriggerCommand {
    24  	tc.serverDetails = serverDetails
    25  	return tc
    26  }
    27  
    28  func (tc *TriggerCommand) SetBranch(br string) *TriggerCommand {
    29  	tc.branch = br
    30  	return tc
    31  }
    32  
    33  func (tc *TriggerCommand) SetPipelineName(pl string) *TriggerCommand {
    34  	tc.pipelineName = pl
    35  	return tc
    36  }
    37  
    38  func (tc *TriggerCommand) SetMultiBranch(multiBranch bool) *TriggerCommand {
    39  	tc.isMultiBranch = multiBranch
    40  	return tc
    41  }
    42  
    43  func (tc *TriggerCommand) CommandName() string {
    44  	return "pl_trigger"
    45  }
    46  
    47  func (tc *TriggerCommand) Run() error {
    48  	serviceManager, err := manager.CreateServiceManager(tc.serverDetails)
    49  	if err != nil {
    50  		return err
    51  	}
    52  	return serviceManager.TriggerPipelineRun(tc.branch, tc.pipelineName, tc.isMultiBranch)
    53  }