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

Add USER_ID variable to be available at the time of promotion if promoted manually

    Details

    • Similar Issues:

      Description

      We have matrix security and in order to execute promotion one should login
      to Jenkins and force the promotion. We need to know who performed the promotion to generate some additional feedback and send email to the user.

      Please add a Jenkins user id to be available at the time of promotion via env variable like PROMOTION_USER_ID when promotion is manually forced.

        Attachments

          Activity

          eguess74 eguess74 created issue -
          Hide
          eguess74 eguess74 added a comment -

          Initially i thought it can be done via promoted builds plugin, but may be Build-user-var-plugin could provide this functionality as well?

          Show
          eguess74 eguess74 added a comment - Initially i thought it can be done via promoted builds plugin, but may be Build-user-var-plugin could provide this functionality as well?
          eguess74 eguess74 made changes -
          Field Original Value New Value
          Assignee Gavriil Konovalenko [ gkonovalenko ]
          Description We have matrix security and in order to execute promotion one should login
          to Jenkins and force the promotion. We need to know who performed the promotion to generate some additional feedback and send email to the user.

          Please add a Jenkins user id to be available at the time of promotion via env variable like USER_ID or PROMOTION_USER_ID when promotion is manually forced.
          We have matrix security and in order to execute promotion one should login
          to Jenkins and force the promotion. We need to know who performed the promotion to generate some additional feedback and send email to the user.

          Please add a Jenkins user id to be available at the time of promotion via env variable like PROMOTION_USER_ID when promotion is manually forced.
          jglick Jesse Glick made changes -
          Issue Type Bug [ 1 ] Improvement [ 4 ]
          Hide
          jmckinzie John McKinzie added a comment -

          This would be extremely helpful.

          Show
          jmckinzie John McKinzie added a comment - This would be extremely helpful.
          jglick Jesse Glick made changes -
          Summary Add USER_ID variable to be available at the time of promotion it promoted manually Add USER_ID variable to be available at the time of promotion if promoted manually
          Issue Type Improvement [ 4 ] New Feature [ 2 ]
          jglick Jesse Glick made changes -
          Assignee Gavriil Konovalenko [ gkonovalenko ] Christopher Chong [ cchong ]
          URL https://github.com/jenkinsci/promoted-builds-plugin/pull/37
          jglick Jesse Glick made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Stephen Connolly
          Path:
          src/main/java/hudson/plugins/promoted_builds/Promotion.java
          src/test/java/hudson/plugins/promoted_builds/PromotionEnvironmentVariablesTest.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/eeb9e6549399d9a3bce6d842db7976d8ed59a7ed
          Log:
          Merge pull request #37 from cchong/master

          [FIXED JENKINS-16063] Added PROMOTED_USER_NAME environment variable

          Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/fd95bf40bc22...eeb9e6549399

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: src/main/java/hudson/plugins/promoted_builds/Promotion.java src/test/java/hudson/plugins/promoted_builds/PromotionEnvironmentVariablesTest.java http://jenkins-ci.org/commit/promoted-builds-plugin/eeb9e6549399d9a3bce6d842db7976d8ed59a7ed Log: Merge pull request #37 from cchong/master [FIXED JENKINS-16063] Added PROMOTED_USER_NAME environment variable Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/fd95bf40bc22...eeb9e6549399
          scm_issue_link SCM/JIRA link daemon made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          eguess74 eguess74 added a comment - - edited

          Thanks for taking care of that!
          It would probably be a little bit simpler to use if it would be USER_ID and not the full name.
          I needed to send email to the promotion user from promotion script and to get the address i used the following workaround:

          create groovy script

          import jenkins.*
          import jenkins.model.*
          import hudson.*
          import hudson.model.*

          name = args[0]
          user = Jenkins.getInstance().getUser(name)
          properties = user.getProperties()

          for (item in properties){
          if (item.value instanceof hudson.tasks.Mailer.UserProperty){}
          println(item.value.getAddress())
          }

          Then execute this during the promotion and pass the $PROMOTED_USER_NAME to get the email address for further work.

          Show
          eguess74 eguess74 added a comment - - edited Thanks for taking care of that! It would probably be a little bit simpler to use if it would be USER_ID and not the full name. I needed to send email to the promotion user from promotion script and to get the address i used the following workaround: create groovy script import jenkins.* import jenkins.model.* import hudson.* import hudson.model.* name = args [0] user = Jenkins.getInstance().getUser(name) properties = user.getProperties() for (item in properties){ if (item.value instanceof hudson.tasks.Mailer.UserProperty){} println(item.value.getAddress()) } Then execute this during the promotion and pass the $PROMOTED_USER_NAME to get the email address for further work.
          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          Reopening the issue USER_ID and USER_NAME are different things

          There is also a PR, which needs to be reworked a bit. https://github.com/jenkinsci/promoted-builds-plugin/pull/52

          Show
          oleg_nenashev Oleg Nenashev added a comment - Reopening the issue USER_ID and USER_NAME are different things There is also a PR, which needs to be reworked a bit. https://github.com/jenkinsci/promoted-builds-plugin/pull/52
          oleg_nenashev Oleg Nenashev made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Assignee Christopher Chong [ cchong ] Oleg Nenashev [ oleg_nenashev ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          src/main/java/hudson/plugins/promoted_builds/Promotion.java
          src/main/java/hudson/plugins/promoted_builds/conditions/ManualCondition.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/4fa8d6f2cc530d4c881afab3deb0901ac091836b
          Log:
          [FIXED JENKINS-16063] - Fix the implementations of getUserName() and getUserId() methods

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/main/java/hudson/plugins/promoted_builds/Promotion.java src/main/java/hudson/plugins/promoted_builds/conditions/ManualCondition.java http://jenkins-ci.org/commit/promoted-builds-plugin/4fa8d6f2cc530d4c881afab3deb0901ac091836b Log: [FIXED JENKINS-16063] - Fix the implementations of getUserName() and getUserId() methods
          scm_issue_link SCM/JIRA link daemon made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          src/main/java/hudson/plugins/promoted_builds/Promotion.java
          src/main/java/hudson/plugins/promoted_builds/conditions/ManualCondition.java
          src/test/java/hudson/plugins/promoted_builds/PromotionEnvironmentVariablesTest.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/c34605266948377c7de8432e3caeef293896f171
          Log:
          Merge pull request #65 from oleg-nenashev/JENKINS-16063

          JENKINS-16063 - Inject PROMOTED_USER_ID variable + minor issue fixes

          Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/84bf6f94e950...c34605266948

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: src/main/java/hudson/plugins/promoted_builds/Promotion.java src/main/java/hudson/plugins/promoted_builds/conditions/ManualCondition.java src/test/java/hudson/plugins/promoted_builds/PromotionEnvironmentVariablesTest.java http://jenkins-ci.org/commit/promoted-builds-plugin/c34605266948377c7de8432e3caeef293896f171 Log: Merge pull request #65 from oleg-nenashev/ JENKINS-16063 JENKINS-16063 - Inject PROMOTED_USER_ID variable + minor issue fixes Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/84bf6f94e950...c34605266948
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 146865 ] JNJira + In-Review [ 192121 ]

            People

            • Assignee:
              oleg_nenashev Oleg Nenashev
              Reporter:
              eguess74 eguess74
            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: