jfrog-pipelines

Is there a way to configure a JFrog pipelines step that will only run for specific branches like master?


I want this step to only execute on the master branch

- name: test_step
  type: Bash          
  execution:
    onExecute:
      - echo 'Hello world'

How do I ensure that this step only runs on the master branch?


Solution

  • Yes, we can execute any step based on condition using condition workflows https://www.jfrog.com/confluence/display/JFROG/Conditional+Workflows

    In order to achieve your scenario, you can do something like:

    - name: test_step
      type: Bash   
      configuration:
        condition: '{{gitBranch}} == master'       
      execution:
        onExecute:
          - echo 'Hello world'
    

    where {{gitBranch}} is a pipeline variable available to be used in pipelines yml and can be used as a placeholder for whatever branch the pipeline was loaded from. When Pipelines syncs from the pipeline source, it automatically replaces any occurrence of {{gitBranch}} with the name of the current branch.