0

I want to refer/specify (syntax) branch which is set as an environment variable for Jenkins shared library which will be provide during docker container. For Example:

@Library(['my-shared-library', BRANCH_NAME])

Tried using ${BRANCH_NAME} ${env.BRANCH_NAME}

I will provide BRANCH_NAME as environment variable in docker-compose.yml

Also i want to get the env variable effected in org.jenkinsci.plugins.workflow.libs.GlobalLibraries.xml

like if i set PIPELINE_VERSION as env variable

<?xml version='1.1' encoding='UTF-8'?>
<org.jenkinsci.plugins.workflow.libs.GlobalLibraries plugin="workflow-cps-global-lib@2.15">
  <libraries>
    <org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
      <name>XXXXXXXXXXXX</name>
      <retriever class="org.jenkinsci.plugins.workflow.libs.SCMSourceRetriever">
        <scm class="jenkins.plugins.git.GitSCMSource" plugin="git@3.12.0">
          <id>XXXXXXXXXXXXXXXXXXXXXXXX</id>
          <remote>XXXXXXXXXXXXXXXXXXX</remote>
          <credentialsId>jXXXXXXXXXXXXXXXXXXXX</credentialsId>
          <traits>
            <jenkins.plugins.git.traits.BranchDiscoveryTrait/>
          </traits>
        </scm>
      </retriever>
      <defaultVersion>${PIPELINE_RELEASE_VERSION}</defaultVersion>
      <implicit>true</implicit>
      <allowVersionOverride>true</allowVersionOverride>
      <includeInChangesets>false</includeInChangesets>
    </org.jenkinsci.plugins.workflow.libs.LibraryConfiguration>
  </libraries>
</org.jenkinsci.plugins.workflow.libs.GlobalLibraries>

Thanks, Kusuma

kusumat
  • 319
  • 3
  • 9
  • 21

1 Answers1

0

I don't think anyway it possible to make the environment variable available for org.jenkinsci.plugins.workflow.libs.GlobalLibraries.xml. But If you use Jenkins Code As Configuration plugins, you can pass the variable from docker-compose and make that available to the config file, and when Jenkins load the config file to prepare config for Jenkins would work. An example can be found here

Samit Kumar Patel
  • 1,932
  • 1
  • 13
  • 20