2

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?

Vivek Kodira
  • 2,764
  • 4
  • 31
  • 49
  • Jfrog is a company, not a tool or product. What product are you talking about? Artifactory? If so, use [tag:artifactory] instead. Please do not use the [tag:jfrog] tag. – TylerH Dec 16 '22 at 21:07
  • @TylerH Sure. Was trying to be consistent with other questions asked about jfrog products. I see you've removed this tag on other questions as well. – Vivek Kodira Dec 20 '22 at 04:49
  • 1
    Yep, since the [tag:jfrog] tag refers to Artifactory specifically, and there's already an [tag:artifactory] tag (which has far more followers and far more uses), there's no point in having [tag:jfrog] stick around, so I am removing it/replacing it with [tag:artifactory] bit by bit. Once the process is completed I can ask a mod to rename [tag:artifactory] to [tag:jfrog-artifactory]. I am doing it this way instead of just having the tags merged/synonymized because not everyone reads tag wiki descriptions, so some uses of the tag are on Qs that have nothing to do with Artifactory. – TylerH Dec 20 '22 at 15:04
  • @TylerH just discovered this today and thought you might find it useful if you didn't already know of it: https://meta.stackoverflow.com/questions/324070/what-is-the-process-for-tag-removal-burnination – Vivek Kodira Jan 12 '23 at 06:22

1 Answers1

3

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.

Deepika Banoth
  • 361
  • 1
  • 3