Search code examples
gradlegitlabpipelinecicd

how to set global environment variable in gitLab ci/cd pipeline?


I have a gradle project in which a file (setting.gradle) which requires artifactory user and artifactory password to download all dependencies.
So for local we put these values in gradle.propeties file and it works well. So I put these artifactory user and artifactory password in gitlab variable (setting -> CI/CD -> variable-> Add variable). But now my setting.gradle unable to fetch these value. After some research I found out that these variable are not gobal. Can some one help me how put these value as gobal or let me know if I am doing something wrong. Thanks in advance for help.


Solution

  • If your gradle project reads variables only from gradle.properties then you can append those variables in your file

    script:
    - 'echo variable_1= $variable_1 >> gradle.properties'
    - 'echo variable_2= $variable_2 >> gradle.properties'