Gitlab: Make required variables when running pipeline
Asked Answered
P

1

8

I want the some of the variables should be required before executing the pipeline in gitlab. Can I achieve it. I have below gitlab-ci.yml

stages:          # Runs First - Anything that needs to run prior to your scripts running
  - deploy
  - Script

variables:
  Domain:
    value: "dom"
  HOST_NAME:
    value: ""  
  JAVA_FILES_WITH_ARGS:
    value: ""
  

I want to make mandatory(JAVA_FILES_WITH_ARGS, HOST_NAME) before run the pipeline how can I achieve it. it will not start the pipeline without these two variable values.

Paraesthesia answered 27/10, 2021 at 7:55 Comment(2)
#69674502 might be the right approachPantile
Simon how to give custom error mesage instead "No stages and Pipeline" when it allow not to proceedParaesthesia
P
4

The Answer: is

rules:
 - if: '$JAVA_FILES_WITH_ARGS != "" && $HOST_NAME != ""'
   allow_failure: true
Paraesthesia answered 27/10, 2021 at 9:48 Comment(2)
@Kappacake i've made the suggested editsOcko
Further reference: docs.gitlab.com/ee/ci/jobs/job_rules.htmlDelegate

© 2022 - 2024 — McMap. All rights reserved.