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

Support ${CAUSE_BUILD_URL} also in addition to ${CAUSE}

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Currently there is ${CAUSE} that prints the upstream job that triggered this build. It would be nice to have a the details of the cause available in tokens also, especially the URL. Then the mail can contain a clickable link, which is quite convenient in some case then a build pipeline exists, where one want to get to the "main" job directly.

      Having these token available would be really nice:

      • ${CAUSE_BUILD_URL}: equivalent of ${BUILD_URL
      • ${CAUSE_PROJECT_NAME}: equivalent of ${PROJECT_NAME
      • ${CAUSE_BUILD_NUMBER}: equivalent of ${BUILD_NUMBER

        Attachments

          Activity

          Hide
          axelh Axel Heider added a comment - - edited

          Not sure what's the preferred way to handle this. Besides creating more variables, using the token-parameters approach might also work and scale nicer:

          • ${CAUSE,data="BUILD_URL"}
          • ${CAUSE,data="PROJECT_NAME"}
          • ${CAUSE,data="BUILD_NUMBER"}
          Show
          axelh Axel Heider added a comment - - edited Not sure what's the preferred way to handle this. Besides creating more variables, using the token-parameters approach might also work and scale nicer: ${CAUSE,data="BUILD_URL" } ${CAUSE,data="PROJECT_NAME" } ${CAUSE,data="BUILD_NUMBER" }
          Hide
          slide_o_mix Alex Earl added a comment -

          The Cause object itself doesn't give anything but the getShortDescription. I can get the upstream job by checking if the Cause is an UpstreamCause, but some macros require a workspace which I would not have access to. It could cause issues for people trying to use some macros with the upstream job.

          Show
          slide_o_mix Alex Earl added a comment - The Cause object itself doesn't give anything but the getShortDescription. I can get the upstream job by checking if the Cause is an UpstreamCause, but some macros require a workspace which I would not have access to. It could cause issues for people trying to use some macros with the upstream job.
          Hide
          axelh Axel Heider added a comment -

          Not sure I follow here. How is the workspace related to this? In my "black box" view all it takes is getting a link to the job that triggered it - if there is one. If there is no job, then this would not work and the macro is empty. Or well, ir could give the user name,so

          • "BUILD_URL" should be just "URL" would link to the jenkins user's page.
          • "PROJECT_NAME" is the user's name as string
          • "BUILD_NUMBER" is empty.

          I wonder, how many "causes" are there besides "job" and "user"?

          Show
          axelh Axel Heider added a comment - Not sure I follow here. How is the workspace related to this? In my "black box" view all it takes is getting a link to the job that triggered it - if there is one. If there is no job, then this would not work and the macro is empty. Or well, ir could give the user name,so "BUILD_URL" should be just "URL" would link to the jenkins user's page. "PROJECT_NAME" is the user's name as string "BUILD_NUMBER" is empty. I wonder, how many "causes" are there besides "job" and "user"?
          Hide
          slide_o_mix Alex Earl added a comment -

          In order to make it scalable, I would want to call the macro expansion with the upstream run as the run for the expansion. Some macros require a workspace. This would be a problem

          Show
          slide_o_mix Alex Earl added a comment - In order to make it scalable, I would want to call the macro expansion with the upstream run as the run for the expansion. Some macros require a workspace. This would be a problem
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/org/jenkinsci/plugins/tokenmacro/impl/BuildCauseMacro.java
          src/test/java/org/jenkinsci/plugins/tokenmacro/impl/BuildCauseMacroTest.java
          http://jenkins-ci.org/commit/token-macro-plugin/4d24aa5716f8d84e236824ab36d87c90a9897e8d
          Log:
          Fix JENKINS-42699

          • Add data parameter which can accept BUILD_URL, PROJECT_NAME, or BUILD_NUMBER
          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/org/jenkinsci/plugins/tokenmacro/impl/BuildCauseMacro.java src/test/java/org/jenkinsci/plugins/tokenmacro/impl/BuildCauseMacroTest.java http://jenkins-ci.org/commit/token-macro-plugin/4d24aa5716f8d84e236824ab36d87c90a9897e8d Log: Fix JENKINS-42699 Add data parameter which can accept BUILD_URL, PROJECT_NAME, or BUILD_NUMBER
          Hide
          slide_o_mix Alex Earl added a comment -

          Fixed in 2.4 (released soon)

          Show
          slide_o_mix Alex Earl added a comment - Fixed in 2.4 (released soon)
          Hide
          axelh Axel Heider added a comment -

          Thanks!

          Show
          axelh Axel Heider added a comment - Thanks!

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              axelh Axel Heider
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: