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

[1.1.0] Generic shell script with parameter will not work

      I'm trying to use postbuildscript plugin to run a shell script after build. This shell script will need parameters pass in. However, if I add parameter in generic script command line,  it will not execute it. No error, just like silently skipped.

          [JENKINS-48179] [1.1.0] Generic shell script with parameter will not work

          Daniel Heid added a comment -

          Thanks again!

          Daniel Heid added a comment - Thanks again!

          Daniel Heid added a comment -

          Sorry, but I cannot reproduce the problem. How did you declare the parameter? Do you mean job parameters? The plugin can currently only handle enviroment variables. Please have a look at the attached example job. The parameter will be displayed.

          build-success.tar.gz

          Daniel Heid added a comment - Sorry, but I cannot reproduce the problem. How did you declare the parameter? Do you mean job parameters? The plugin can currently only handle enviroment variables. Please have a look at the attached example job. The parameter will be displayed. build-success.tar.gz

          Wei Gao added a comment - - edited

          My scenario like this:

          I use jenkins docker plugin (YAD) to start a jenkins slave container, and this slave container will create a network, start some container (as dependency services) and then test. After test done, it will call tear_down.sh to stop dependency containers, remove them and so on. Same script working fine when use post build steps plugin. But I like post build script plugin as no matter test success or failed, it should always execute it, and execution result shouldn't change test result.

           

          Here is the output of post build script. You can see, after try to call "/tmp/jenkinsxxxx.sh" with parameter, but it not doing anything, and then go to next step (recording test results).

           

          [PostBuildScript] - Executing post build scripts.

          [YAD-PLUGIN] Injecting variable: DOCKER_CONTAINER_ID

          [YAD-PLUGIN] Injecting variable: JENKINS_CLOUD_ID

          [YAD-PLUGIN] Injecting variable: DOCKER_HOST

          [PostBuildScript] - Executing the script /usr/bin/tear_down.sh with parameters [tcp://docker-swarm-manager:3376, /workspace/docker-compose.yml].

          [sample_tests_DISABLED] $ /bin/sh -xe /tmp/jenkins2753822486687003701.sh tcp://docker-swarm-manager:3376 /workspace/docker-compose.yml

          Recording test results

           

          Let me know what else can I provide in order to reproduce it.

           

          Thanks

          Wei Gao added a comment - - edited My scenario like this: I use jenkins docker plugin (YAD) to start a jenkins slave container, and this slave container will create a network, start some container (as dependency services) and then test. After test done, it will call tear_down.sh to stop dependency containers, remove them and so on. Same script working fine when use post build steps plugin. But I like post build script plugin as no matter test success or failed, it should always execute it, and execution result shouldn't change test result.   Here is the output of post build script. You can see, after try to call "/tmp/jenkinsxxxx.sh" with parameter, but it not doing anything, and then go to next step (recording test results).   [PostBuildScript] - Executing post build scripts. [YAD-PLUGIN] Injecting variable: DOCKER_CONTAINER_ID [YAD-PLUGIN] Injecting variable: JENKINS_CLOUD_ID [YAD-PLUGIN] Injecting variable: DOCKER_HOST [PostBuildScript] - Executing the script /usr/bin/tear_down.sh with parameters [tcp://docker-swarm-manager:3376, /workspace/docker-compose.yml] . [sample_tests_DISABLED] $ /bin/sh -xe /tmp/jenkins2753822486687003701.sh tcp://docker-swarm-manager:3376 /workspace/docker-compose.yml Recording test results   Let me know what else can I provide in order to reproduce it.   Thanks

          Daniel Heid added a comment -

          Sorry for reacting so late to your comment

          Does the tear_down.sh script use the environment variables DOCKER_CONTAINER_ID, JENKINS_CLOUD_ID and DOCKER_HOST? Perhaps this has something to with the environment parameter injection.

          Is it possible to post the tear_down.sh script?

          Daniel Heid added a comment - Sorry for reacting so late to your comment Does the tear_down.sh script use the environment variables DOCKER_CONTAINER_ID, JENKINS_CLOUD_ID and DOCKER_HOST? Perhaps this has something to with the environment parameter injection. Is it possible to post the tear_down.sh script?

          Daniel Heid added a comment -

          Closing the issue due to lack of information.

          Daniel Heid added a comment - Closing the issue due to lack of information.

            dheid Daniel Heid
            weigao Wei Gao
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: