Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-26886

Variables not being substituted in github URLs for $JOB_NAME

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • github-plugin
    • Jenkins1.594, GitHub plugin 1.10

      The release notes for 1.10 github plugin mention that it now supports variable substitution.

      But that seems not to work, at least for the value of "JOB_NAME"

      We name our Jenkins projects based on the github project name, and that allows us to setup a template with the following url for the project on github:

      https://github.com/mycompany/$JOB_NAME/

      But, when you click on the GitHub link in the left hand notification, the link is still to /$JOB_NAME/ – not the actual substituted name of the job.

          [JENKINS-26886] Variables not being substituted in github URLs for $JOB_NAME

          Have you tried

           ${JOB_NAME} 
          

          ?

          Kanstantsin Shautsou added a comment - Have you tried ${JOB_NAME} ?

          This var substitution works only in some context with environment. This context is usually build. So when there is no any context, variable substitution can't work. I can think about replacing some of variables, but it will be not all of defined in build scope

          Kirill Merkushev added a comment - This var substitution works only in some context with environment. This context is usually build. So when there is no any context, variable substitution can't work. I can think about replacing some of variables, but it will be not all of defined in build scope

          No replies - closing.

          Kanstantsin Shautsou added a comment - No replies - closing.

          Laurent TOURREAU added a comment - - edited

          I reopen this issue because i have a similar problem with GitHub plugin 1.25.1 / Jenkins 2.32.1
          I create a Jenkins variable environment on System configuration screen:
          GITHUB_BASE_URL = https://mygihubentrepriseurl.com

          On Project Url field in my job i enter this value :
          ${GITHUB_BASE_URL}/MyOrg/MyProject

          Result : On the left pane of job page the GitHub button points to the job page URL instead of pointing to GitHub URL i mentionned on the Project URL field.

          What's wrong?

          Laurent TOURREAU added a comment - - edited I reopen this issue because i have a similar problem with GitHub plugin 1.25.1 / Jenkins 2.32.1 I create a Jenkins variable environment on System configuration screen: GITHUB_BASE_URL = https://mygihubentrepriseurl.com On Project Url field in my job i enter this value : ${GITHUB_BASE_URL}/MyOrg/MyProject Result : On the left pane of job page the GitHub button points to the job page URL instead of pointing to GitHub URL i mentionned on the Project URL field. What's wrong?

          Now it knows nothing about env vars of jenkins. It should be implemented.

          Kirill Merkushev added a comment - Now it knows nothing about env vars of jenkins. It should be implemented.

          The problem persists with $JOB_NAME. I also tried ${JOB_NAME}, substitution is not done.
          It is difficult to define a job template without using variables.

          Laurent TOURREAU added a comment - The problem persists with $JOB_NAME. I also tried ${JOB_NAME}, substitution is not done. It is difficult to define a job template without using variables.

          When triggering works it knows nothing about environment variables, env vars exists only in build context while polling works outside of build context.

          Kanstantsin Shautsou added a comment - When triggering works it knows nothing about environment variables, env vars exists only in build context while polling works outside of build context.

          About what templates are you talking? It pretty simple to generate full url with job-dsl-plugin.

          Kanstantsin Shautsou added a comment - About what templates are you talking? It pretty simple to generate full url with job-dsl-plugin.

          integer : You said "env vars exists only in build context" -> I now understand that.
          What i would like is to avoid configuration duplication between jobs.
          All the jobs have the same base GitHub URL -> Having the GitHub base URL in a variable can help to reduce the maintenance effort if i have to change the GitHub host URL on hundred jobs.
          Moreover it avoid to duplicate the base URL in the same job because the URL is the same on SCM configuration section.

          According to you the best solution is to generate the jobs using dsl plugin to avoid such overhead?

          Laurent TOURREAU added a comment - integer : You said "env vars exists only in build context" -> I now understand that. What i would like is to avoid configuration duplication between jobs. All the jobs have the same base GitHub URL -> Having the GitHub base URL in a variable can help to reduce the maintenance effort if i have to change the GitHub host URL on hundred jobs. Moreover it avoid to duplicate the base URL in the same job because the URL is the same on SCM configuration section. According to you the best solution is to generate the jobs using dsl plugin to avoid such overhead?

            Unassigned Unassigned
            gregcovertsmith Greg Smith
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: