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

Cannot access TestLink environment variables within Jenkins build

    XMLWordPrintable

Details

    Description

      I'm configuring my first Jenkins / TestLink job. I don't seem to have access to any of the TestLink environment variables. I have pared down my Jenkins job to the following two statements under Build / Invoke TestLink / Test Execution / Single Build Steps / Execute Shell:

      echo "Test plan name is: $TESTLINK_TESTPLAN_NAME"
      echo "Build number is: $BUILD_NUMBER"

      The Jenkins console output is as follows:

      Started by user lisas
      Building in workspace /var/lib/jenkins/jobs/Website-Linkchecker-TestLink-integration/workspace
      Preparing TestLink client API.
      Using TestLink URL: http://localhost/testlink/lib/api/xmlrpc.php

      Found 1 automated test cases in TestLink.

      Sorting automated test cases by TestLink test plan execution order.

      Executing single Build Steps.

      [workspace] $ /bin/sh -xe /tmp/hudson8927570372825500742.sh
      + echo Test plan name is:
      Test plan name is:
      + echo Build number is: 8
      Build number is: 8
      Executing iterative Build Steps.

      Looking for the test results of TestLink test cases.

      Found 0 test result(s).

      Finished: SUCCESS

      As you can see, the $BUILD_NUMBER environment variable is translated as expected. The $TESTLINK_TESTPLAN_NAME environment variable is not.

      Any hints as to what might have gone wrong?

      Attachments

        Activity

          has_lisa_stanley Lisa Stanley added a comment -

          Info I forgot to add:

          Jenkins version: 1.509
          TestLink version: 1.9.6
          Plugin version: 3.3

          has_lisa_stanley Lisa Stanley added a comment - Info I forgot to add: Jenkins version: 1.509 TestLink version: 1.9.6 Plugin version: 3.3

          Hi Lisa

          tl;dr: this information is (unfortunately) not available for single build steps.

          In the first versions of the plug-in, there were only iterative build steps. And during a huge code refactoring we added the result seeking strategies, but we didn't add environment variables to single build steps.

          I can't recall if there was any limitation, maybe in the TestLink XML-RPC API... I'll take a look on it, but if you have spare time to send a pull request, or any suggestions or questions just let me know :o)

          Thanks and sorry for missing this. I even had to use it once and I think I use some quick n' dirty script for that...

          /Bruno

          kinow Bruno P. Kinoshita added a comment - Hi Lisa tl;dr: this information is (unfortunately) not available for single build steps. In the first versions of the plug-in, there were only iterative build steps. And during a huge code refactoring we added the result seeking strategies, but we didn't add environment variables to single build steps. I can't recall if there was any limitation, maybe in the TestLink XML-RPC API... I'll take a look on it, but if you have spare time to send a pull request, or any suggestions or questions just let me know :o) Thanks and sorry for missing this. I even had to use it once and I think I use some quick n' dirty script for that... /Bruno

          BTW, I work in cycles on the Open Source tools that I contribute to, my Jenkins cycle is ending this week, so if you have any other bugs, issues, features, etc, try to send it all and we'll see if we can include in this week's release

          kinow Bruno P. Kinoshita added a comment - BTW, I work in cycles on the Open Source tools that I contribute to, my Jenkins cycle is ending this week, so if you have any other bugs, issues, features, etc, try to send it all and we'll see if we can include in this week's release
          has_lisa_stanley Lisa Stanley added a comment -

          Bruno,

          Many thanks for the incredibly quick response! I'm mostly relieved that I wasn't doing something silly, since these tools are very new to me. I have moved my echo statements to the iterative build steps and confirmed that the results are as expected. So now I know what I have to work with for today.

          I'll see if I can generate any more requests for you this week!

          Thanks again for the very quick response.
          — Lisa

          has_lisa_stanley Lisa Stanley added a comment - Bruno, Many thanks for the incredibly quick response! I'm mostly relieved that I wasn't doing something silly, since these tools are very new to me. I have moved my echo statements to the iterative build steps and confirmed that the results are as expected. So now I know what I have to work with for today. I'll see if I can generate any more requests for you this week! Thanks again for the very quick response. — Lisa

          No worries Lisa, I was working on other issues for the next release. Keep an eye in the commit log, I'll try to include this issue in the next release.

          Cheers, /B

          kinow Bruno P. Kinoshita added a comment - No worries Lisa, I was working on other issues for the next release. Keep an eye in the commit log, I'll try to include this issue in the next release. Cheers, /B

          For the single build steps, the following environment variables have been added:

          • TESTLINK_BUILD_NAME - build name
          • TESTLINK_TESTPLAN_NAME - test plan name
          • TESTLINK_TESTPROJECT_NAME - test project name
          • TESTLINK_TESTCASE_TOTAL - number of test cases

          The names are compatible with the ones used in the iterative build steps, easing to adapt scripts.

          Although test cases could have been added too, as TESTCASE_1_NAME, TESTCASE_2_NAME, etc, having hundreds or thousands of test cases in a build could cause troubles in the server. Thus, the recommended practice is use the single and iterative build steps together when needed, or only the one more applicable for your scenario.

          kinow Bruno P. Kinoshita added a comment - For the single build steps, the following environment variables have been added: TESTLINK_BUILD_NAME - build name TESTLINK_TESTPLAN_NAME - test plan name TESTLINK_TESTPROJECT_NAME - test project name TESTLINK_TESTCASE_TOTAL - number of test cases The names are compatible with the ones used in the iterative build steps, easing to adapt scripts. Although test cases could have been added too, as TESTCASE_1_NAME, TESTCASE_2_NAME, etc, having hundreds or thousands of test cases in a build could cause troubles in the server. Thus, the recommended practice is use the single and iterative build steps together when needed, or only the one more applicable for your scenario.

          Wiki updated.

          kinow Bruno P. Kinoshita added a comment - Wiki updated.

          Code changed in jenkins
          User: Bruno P. Kinoshita
          Path:
          src/main/java/hudson/plugins/testlink/TestLinkBuilder.java
          src/main/java/hudson/plugins/testlink/util/TestLinkHelper.java
          http://jenkins-ci.org/commit/testlink-plugin/013dd77d0e840b0c0d4ac77959876f4b06bae52b
          Log:
          [FIXED JENKINS-17622] Added env vars to single build steps

          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Bruno P. Kinoshita Path: src/main/java/hudson/plugins/testlink/TestLinkBuilder.java src/main/java/hudson/plugins/testlink/util/TestLinkHelper.java http://jenkins-ci.org/commit/testlink-plugin/013dd77d0e840b0c0d4ac77959876f4b06bae52b Log: [FIXED JENKINS-17622] Added env vars to single build steps

          Fixed in 3.5

          kinow Bruno P. Kinoshita added a comment - Fixed in 3.5
          has_lisa_stanley Lisa Stanley added a comment -

          Thank you!!!

          has_lisa_stanley Lisa Stanley added a comment - Thank you!!!

          People

            kinow Bruno P. Kinoshita
            has_lisa_stanley Lisa Stanley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: