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

Remote directory of a Transfer Set should resolve env variable more than once

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      This is a small feature improvement for "Publish Over ..."

      I tested the plugin beforehand (1.7) and read this information:

      https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+...#PublishOver...-Remotedirectory

      https://wiki.jenkins-ci.org/display/JENKINS/Publish+Over+...#PublishOver...-examples

      The "Eg 3 Environment variables" works for variables that need be resolved only once (e.g $JOB_NAME/$BUILD_NUMBER)

      However, this won't work with a variable $MY_JOB_PARAM that is defined as $JOB_NAME/$BUILD_NUMBER.

      Would it be possible to have a mechanism to resolve the env variable more than once? Possibly, the level of resolution could be specified by a number to enter.

        Attachments

          Activity

          Hide
          slide_o_mix Alex Earl added a comment -

          Might be useful to integrate token macro

          Show
          slide_o_mix Alex Earl added a comment - Might be useful to integrate token macro
          Hide
          chantivlad chanti vlad added a comment -

          So you suggest "Publish Over ..." to integrate following plugin https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin right ?

          Show
          chantivlad chanti vlad added a comment - So you suggest "Publish Over ..." to integrate following plugin https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin right ?
          Hide
          slide_o_mix Alex Earl added a comment -

          Yes, that is my thought.

          Show
          slide_o_mix Alex Earl added a comment - Yes, that is my thought.
          Hide
          chantivlad chanti vlad added a comment -

          Could you please have a look at the solution proposed by Slide-O-Mix?
          This looks really promising and could allow a more powerful handling of variables within the plugin.
          Thanks a lot in advance.

          Show
          chantivlad chanti vlad added a comment - Could you please have a look at the solution proposed by Slide-O-Mix? This looks really promising and could allow a more powerful handling of variables within the plugin. Thanks a lot in advance.
          Hide
          bap bap added a comment -

          This is non trivial due to the way variables are currently resolved in the publish over plugins.

          I will look into it at some point, and see if the token macro plugin can be used to resolve variables without affecting the current behaviour.

          Show
          bap bap added a comment - This is non trivial due to the way variables are currently resolved in the publish over plugins. I will look into it at some point, and see if the token macro plugin can be used to resolve variables without affecting the current behaviour.
          Hide
          chantivlad chanti vlad added a comment - - edited

          I guess this relates to my request https://issues.jenkins-ci.org/browse/JENKINS-14340.
          I see the need to resolve "natural" environment variables and parameters as more natural though since "Free style job" does it in a shell build step, and Publish Over SSH does not do it in "Send files or execute commands over SSH after the build runs".

          Here is a easy job config.xml for reproducing the issue on 1.486 with publish over SSH 1.9:

          <?xml version='1.0' encoding='UTF-8'?>
          <project>
            <actions/>
            <description></description>
            <keepDependencies>false</keepDependencies>
            <properties>
              <hudson.model.ParametersDefinitionProperty>
                <parameterDefinitions>
                  <hudson.model.StringParameterDefinition>
                    <name>foo</name>
                    <description></description>
                    <defaultValue>i_am_foo</defaultValue>
                  </hudson.model.StringParameterDefinition>
                  <hudson.model.StringParameterDefinition>
                    <name>bar</name>
                    <description></description>
                    <defaultValue>i_am_bar</defaultValue>
                  </hudson.model.StringParameterDefinition>
                  <hudson.model.StringParameterDefinition>
                    <name>foobar</name>
                    <description></description>
                    <defaultValue>${foo}_${bar}</defaultValue>
                  </hudson.model.StringParameterDefinition>
                </parameterDefinitions>
              </hudson.model.ParametersDefinitionProperty>
            </properties>
            <scm class="hudson.scm.NullSCM"/>
            <canRoam>true</canRoam>
            <disabled>false</disabled>
            <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
            <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
            <triggers class="vector"/>
            <concurrentBuild>false</concurrentBuild>
            <builders>
              <hudson.tasks.Shell>
                <command>#!/bin/bash
          
          echo
          echo &quot;Build Step&quot;
          echo &quot;we have foo=${foo}&quot;
          echo &quot;we have bar=${bar}&quot;
          echo &quot;we have foobar=${foobar}&quot;</command>
              </hudson.tasks.Shell>
            </builders>
            <publishers/>
            <buildWrappers>
              <jenkins.plugins.publish__over__ssh.BapSshPostBuildWrapper plugin="publish-over-ssh@1.9">
                <postBuild>
                  <consolePrefix>SSH: </consolePrefix>
                  <delegate>
                    <publishers>
                      <jenkins.plugins.publish__over__ssh.BapSshPublisher>
                        <configName>TempArtifacts_deployer</configName>
                        <verbose>false</verbose>
                        <transfers>
                          <jenkins.plugins.publish__over__ssh.BapSshTransfer>
                            <remoteDirectory></remoteDirectory>
                            <sourceFiles></sourceFiles>
                            <excludes></excludes>
                            <removePrefix></removePrefix>
                            <remoteDirectorySDF>false</remoteDirectorySDF>
                            <flatten>false</flatten>
                            <cleanRemote>false</cleanRemote>
                            <noDefaultExcludes>false</noDefaultExcludes>
                            <makeEmptyDirs>false</makeEmptyDirs>
                            <execCommand>#!/bin/bash
          
          echo
          echo &quot;SSH deployer after the build runs&quot;
          echo &quot;we have foo=${foo}&quot;
          echo &quot;we have bar=${bar}&quot;
          echo &quot;we have foobar=${foobar}&quot;</execCommand>
                            <execTimeout>120000</execTimeout>
                            <usePty>false</usePty>
                          </jenkins.plugins.publish__over__ssh.BapSshTransfer>
                        </transfers>
                        <useWorkspaceInPromotion>false</useWorkspaceInPromotion>
                        <usePromotionTimestamp>false</usePromotionTimestamp>
                      </jenkins.plugins.publish__over__ssh.BapSshPublisher>
                    </publishers>
                    <continueOnError>false</continueOnError>
                    <failOnError>false</failOnError>
                    <alwaysPublishFromMaster>false</alwaysPublishFromMaster>
                    <hostConfigurationAccess class="jenkins.plugins.publish_over_ssh.BapSshAlwaysRunPublisherPlugin" reference="../.."/>
                  </delegate>
                </postBuild>
              </jenkins.plugins.publish__over__ssh.BapSshPostBuildWrapper>
            </buildWrappers>
          </project>
          

          The output of that job is

          Building remotely on ******** in workspace /****************/PublishOverSSHTest
          [PublishOverSSHTest] $ /bin/bash /tmp/hudson8155249335332678275.sh
          
          Build Step
          we have foo=i_am_foo
          we have bar=i_am_bar
          we have foobar=i_am_foo_i_am_bar
          SSH: Connecting from host [********]
          SSH: Connecting with configuration [********] ...
          SSH: EXEC: STDOUT/STDERR from command [#!/bin/bash
          
          echo
          echo "SSH deployer after the build runs"
          echo "we have foo=i_am_foo"
          echo "we have bar=i_am_bar"
          echo "we have foobar=${foo}_${bar}"] ...
          
          SSH deployer after the build runs
          we have foo=i_am_foo
          we have bar=i_am_bar
          we have foobar=_
          SSH: EXEC: completed after 601 ms
          SSH: Disconnecting configuration [********] ...
          SSH: Transferred 0 file(s)
          Notifying upstream projects of job completion
          Finished: SUCCESS
          
          Show
          chantivlad chanti vlad added a comment - - edited I guess this relates to my request https://issues.jenkins-ci.org/browse/JENKINS-14340 . I see the need to resolve "natural" environment variables and parameters as more natural though since "Free style job" does it in a shell build step, and Publish Over SSH does not do it in "Send files or execute commands over SSH after the build runs". Here is a easy job config.xml for reproducing the issue on 1.486 with publish over SSH 1.9: <?xml version= '1.0' encoding= 'UTF-8' ?> <project> <actions/> <description> </description> <keepDependencies> false </keepDependencies> <properties> <hudson.model.ParametersDefinitionProperty> <parameterDefinitions> <hudson.model.StringParameterDefinition> <name> foo </name> <description> </description> <defaultValue> i_am_foo </defaultValue> </hudson.model.StringParameterDefinition> <hudson.model.StringParameterDefinition> <name> bar </name> <description> </description> <defaultValue> i_am_bar </defaultValue> </hudson.model.StringParameterDefinition> <hudson.model.StringParameterDefinition> <name> foobar </name> <description> </description> <defaultValue> ${foo}_${bar} </defaultValue> </hudson.model.StringParameterDefinition> </parameterDefinitions> </hudson.model.ParametersDefinitionProperty> </properties> <scm class= "hudson.scm.NullSCM" /> <canRoam> true </canRoam> <disabled> false </disabled> <blockBuildWhenDownstreamBuilding> false </blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding> false </blockBuildWhenUpstreamBuilding> <triggers class= "vector" /> <concurrentBuild> false </concurrentBuild> <builders> <hudson.tasks.Shell> <command> #!/bin/bash echo echo &quot;Build Step&quot; echo &quot;we have foo=${foo}&quot; echo &quot;we have bar=${bar}&quot; echo &quot;we have foobar=${foobar}&quot; </command> </hudson.tasks.Shell> </builders> <publishers/> <buildWrappers> <jenkins.plugins.publish__over__ssh.BapSshPostBuildWrapper plugin= "publish-over-ssh@1.9" > <postBuild> <consolePrefix> SSH: </consolePrefix> <delegate> <publishers> <jenkins.plugins.publish__over__ssh.BapSshPublisher> <configName> TempArtifacts_deployer </configName> <verbose> false </verbose> <transfers> <jenkins.plugins.publish__over__ssh.BapSshTransfer> <remoteDirectory> </remoteDirectory> <sourceFiles> </sourceFiles> <excludes> </excludes> <removePrefix> </removePrefix> <remoteDirectorySDF> false </remoteDirectorySDF> <flatten> false </flatten> <cleanRemote> false </cleanRemote> <noDefaultExcludes> false </noDefaultExcludes> <makeEmptyDirs> false </makeEmptyDirs> <execCommand> #!/bin/bash echo echo &quot;SSH deployer after the build runs&quot; echo &quot;we have foo=${foo}&quot; echo &quot;we have bar=${bar}&quot; echo &quot;we have foobar=${foobar}&quot; </execCommand> <execTimeout> 120000 </execTimeout> <usePty> false </usePty> </jenkins.plugins.publish__over__ssh.BapSshTransfer> </transfers> <useWorkspaceInPromotion> false </useWorkspaceInPromotion> <usePromotionTimestamp> false </usePromotionTimestamp> </jenkins.plugins.publish__over__ssh.BapSshPublisher> </publishers> <continueOnError> false </continueOnError> <failOnError> false </failOnError> <alwaysPublishFromMaster> false </alwaysPublishFromMaster> <hostConfigurationAccess class= "jenkins.plugins.publish_over_ssh.BapSshAlwaysRunPublisherPlugin" reference= "../.." /> </delegate> </postBuild> </jenkins.plugins.publish__over__ssh.BapSshPostBuildWrapper> </buildWrappers> </project> The output of that job is Building remotely on ******** in workspace /****************/ PublishOverSSHTest [PublishOverSSHTest] $ /bin/bash /tmp/hudson8155249335332678275.sh Build Step we have foo=i_am_foo we have bar=i_am_bar we have foobar=i_am_foo_i_am_bar SSH: Connecting from host [********] SSH: Connecting with configuration [********] ... SSH: EXEC: STDOUT/STDERR from command [#!/bin/bash echo echo "SSH deployer after the build runs" echo "we have foo=i_am_foo" echo "we have bar=i_am_bar" echo "we have foobar=${foo}_${bar}" ] ... SSH deployer after the build runs we have foo=i_am_foo we have bar=i_am_bar we have foobar=_ SSH: EXEC: completed after 601 ms SSH: Disconnecting configuration [********] ... SSH: Transferred 0 file(s) Notifying upstream projects of job completion Finished: SUCCESS
          Hide
          utopius Florian Herbel added a comment -

          This is increasingly annoying in regard of the promoted builds plugin as the CIFS plugin does not resolve environment variables which are passed to a promotion as parameters. So I have to encapsulate the CIFS publishing in a seperate job.

          Show
          utopius Florian Herbel added a comment - This is increasingly annoying in regard of the promoted builds plugin as the CIFS plugin does not resolve environment variables which are passed to a promotion as parameters. So I have to encapsulate the CIFS publishing in a seperate job.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            chantivlad chanti vlad
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: