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

Default pre-send script in Jenkins Configuration

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • email-ext-plugin
    • None

      It would be very nice, if there is also an input field for a default pre-send script like the default email content and recipients which is triggered if the according placeholder (e.g. ${DEFAULT_PRE-SEND_SCRIPT}) is present in the project configuration.

          [JENKINS-14508] Default pre-send script in Jenkins Configuration

          Alex Earl added a comment -

          Are you wanting this at the global config level?

          Alex Earl added a comment - Are you wanting this at the global config level?

          Markus added a comment -

          That is how at least I'd like it. All the other fields have a global config level DEFAULT option, but the pre-sim script does not. Adding ${DEFAULT_PRE-SEND_SCRIPT} in the pre-sim script field in a job (it should maybe be there by default), should execute a pre-sim script defined globally. It would make it much easier to run the same script on all the jobs.

          An alternative could be to adds support for ${SCRIPT, script="my-default-script.groovy"}, which is fetched from the email-templates directory.

          Or even better - both. Let the pre-sim script behave like all the other fields.

          Markus added a comment - That is how at least I'd like it. All the other fields have a global config level DEFAULT option, but the pre-sim script does not. Adding ${DEFAULT_PRE-SEND_SCRIPT} in the pre-sim script field in a job (it should maybe be there by default), should execute a pre-sim script defined globally. It would make it much easier to run the same script on all the jobs. An alternative could be to adds support for ${SCRIPT, script="my-default-script.groovy"}, which is fetched from the email-templates directory. Or even better - both. Let the pre-sim script behave like all the other fields.

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/AttachmentUtils.java
          src/main/java/hudson/plugins/emailext/EmailToken.java
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java
          src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java
          src/main/java/hudson/plugins/emailext/plugins/EmailToken.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildIdContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildLogContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildLogExcerptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildLogMultilineRegexContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildLogRegexContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildNumberContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildStatusContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/BuildURLContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/CauseContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ChangesSinceLastBuildContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ChangesSinceLastSuccessfulBuildContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ChangesSinceLastUnstableBuildContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/FailedTestsContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/JenkinsURLContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/JobDescriptionContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ProjectNameContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ProjectURLContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/SVNRevisionContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/TestCountsContent.java
          src/main/java/hudson/plugins/emailext/plugins/content/WorkspaceFileContent.java
          src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.groovy
          src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/global.groovy
          src/main/resources/lib/email-ext/tokenhelp.jelly
          src/main/webapp/help/globalConfig/defaultPresendScript.html
          src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/c9e56e459d6fce1dddad937d10d06b9103b6a97d
          Log:
          Fix JENKINS-14508

          Added default presend script and DEFAULT_PRESEND_SCRIPT token to be used in the
          project settings. Also added ability to use content tokens in pre-send script area
          so that the pre-send script could be loaded from the templates area if desired.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/AttachmentUtils.java src/main/java/hudson/plugins/emailext/EmailToken.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/main/java/hudson/plugins/emailext/ExtendedEmailPublisherDescriptor.java src/main/java/hudson/plugins/emailext/plugins/ContentBuilder.java src/main/java/hudson/plugins/emailext/plugins/EmailToken.java src/main/java/hudson/plugins/emailext/plugins/content/BuildIdContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildLogContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildLogExcerptContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildLogMultilineRegexContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildLogRegexContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildNumberContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildStatusContent.java src/main/java/hudson/plugins/emailext/plugins/content/BuildURLContent.java src/main/java/hudson/plugins/emailext/plugins/content/CauseContent.java src/main/java/hudson/plugins/emailext/plugins/content/ChangesSinceLastBuildContent.java src/main/java/hudson/plugins/emailext/plugins/content/ChangesSinceLastSuccessfulBuildContent.java src/main/java/hudson/plugins/emailext/plugins/content/ChangesSinceLastUnstableBuildContent.java src/main/java/hudson/plugins/emailext/plugins/content/FailedTestsContent.java src/main/java/hudson/plugins/emailext/plugins/content/JellyScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/JenkinsURLContent.java src/main/java/hudson/plugins/emailext/plugins/content/JobDescriptionContent.java src/main/java/hudson/plugins/emailext/plugins/content/ProjectNameContent.java src/main/java/hudson/plugins/emailext/plugins/content/ProjectURLContent.java src/main/java/hudson/plugins/emailext/plugins/content/SVNRevisionContent.java src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java src/main/java/hudson/plugins/emailext/plugins/content/TestCountsContent.java src/main/java/hudson/plugins/emailext/plugins/content/WorkspaceFileContent.java src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/config.groovy src/main/resources/hudson/plugins/emailext/ExtendedEmailPublisher/global.groovy src/main/resources/lib/email-ext/tokenhelp.jelly src/main/webapp/help/globalConfig/defaultPresendScript.html src/test/java/hudson/plugins/emailext/plugins/ContentBuilderTest.java http://jenkins-ci.org/commit/email-ext-plugin/c9e56e459d6fce1dddad937d10d06b9103b6a97d Log: Fix JENKINS-14508 Added default presend script and DEFAULT_PRESEND_SCRIPT token to be used in the project settings. Also added ability to use content tokens in pre-send script area so that the pre-send script could be loaded from the templates area if desired.

          Alex Earl added a comment -

          Added default pre-send script

          Alex Earl added a comment - Added default pre-send script

          Markus added a comment -

          Great! Thank you!

          Markus added a comment - Great! Thank you!

          Mac Cer added a comment -

          Hey, is it intended behavior to have the $DEFAULT_PRESEND_SCRIPT be expanded after a Job that had it included in its configuration ran?
          Cause that's what happens with my Jenkins 1.509.4 and Version 2.36 of this plugin.

          I find this a little inconvenient. What if I want to make changes to my script? Every Job that I have set up with "$DEFAULT_PRESEND_SCRIPT" in its configuration would have the old version of that script expanded in its configuration after it ran at least once. I would have to go through every job config and change it back to "$DEFAULT_PRESEND_SCRIPT" to have to load the newest version of that script.

          This expansion happens every time. I tried writing it as $DEFAULT_PRESEND_SCRIPT and ${DEFAULT_PRESEND_SCRIPT}. Both times it gets expanded.

          Mac Cer added a comment - Hey, is it intended behavior to have the $DEFAULT_PRESEND_SCRIPT be expanded after a Job that had it included in its configuration ran? Cause that's what happens with my Jenkins 1.509.4 and Version 2.36 of this plugin. I find this a little inconvenient. What if I want to make changes to my script? Every Job that I have set up with "$DEFAULT_PRESEND_SCRIPT" in its configuration would have the old version of that script expanded in its configuration after it ran at least once. I would have to go through every job config and change it back to "$DEFAULT_PRESEND_SCRIPT" to have to load the newest version of that script. This expansion happens every time. I tried writing it as $DEFAULT_PRESEND_SCRIPT and ${DEFAULT_PRESEND_SCRIPT}. Both times it gets expanded.

          Alex Earl added a comment -

          Can you post a config.xml before and after?

          Alex Earl added a comment - Can you post a config.xml before and after?

          Alex Earl added a comment -

          Also, please file a new issue since the issue you are describing is different from the one this one is describing.

          Alex Earl added a comment - Also, please file a new issue since the issue you are describing is different from the one this one is describing.

            slide_o_mix Alex Earl
            robin_h00d robin_h00d
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: