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

Calling pipeline steps functions gives error that not logged in -- though successfully authenticated in plugin configuration

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • jira-steps-plugin
    • None

      For example, trying to run the code (I changed the issue key)

      def issue = jiraGetIssue site: "JIRA", idOrKey: 'PROJ-12345'
      echo issue.data.toString()

      gives the error message:
      ERROR: {"errorMessages":["You do not have the permission to see the specified issue.","Login Required"],"errors":{}}
      but on the plugin configuration page, a user (that has correct permissions in JIRA) is set up with correct username and password – testing connection shows success. 

        1. Jenkins - Plugin Version.png
          Jenkins - Plugin Version.png
          27 kB
        2. Jenkins - Config.png
          Jenkins - Config.png
          89 kB
        3. Jenkins - Job.png
          Jenkins - Job.png
          129 kB
        4. JIRA - Issue.png
          JIRA - Issue.png
          387 kB
        5. JIRA Home Page.png
          JIRA Home Page.png
          455 kB
        6. Issue.png
          Issue.png
          13 kB
        7. JIRA - version.png
          JIRA - version.png
          23 kB
        8. Jenkins version.png
          Jenkins version.png
          18 kB
        9. Jenkins- Config.png
          Jenkins- Config.png
          40 kB
        10. Login Error (getIssue).png
          Login Error (getIssue).png
          81 kB
        11. getIssue script.png
          getIssue script.png
          11 kB
        12. getProjects script.png
          getProjects script.png
          10 kB
        13. getProjects() success.png
          getProjects() success.png
          36 kB
        14. Empty UserName Password.png
          Empty UserName Password.png
          545 kB

          [JENKINS-44980] Calling pipeline steps functions gives error that not logged in -- though successfully authenticated in plugin configuration

          jdudatt Can you try the following curl command and check if http basic authentication is enabled.

          curl -v https://jira.tradingtechnologies.com/?os_authType=basic
          

          Naresh Rayapati added a comment - jdudatt Can you try the following curl command and check if http basic authentication is enabled. curl -v https: //jira.tradingtechnologies.com/?os_authType=basic

          For me it looks like a problem with basic authentication on the JIRA server that you are referring. probably you could try OAuth?

          Naresh Rayapati added a comment - For me it looks like a problem with basic authentication on the JIRA server that you are referring. probably you could try OAuth?

          jdudatt did you figure this out? 

          Naresh Rayapati added a comment - jdudatt did you figure this out? 

          Justin Duda added a comment -

          Hi, sorry for disappearing, I had to work on other things and haven't yet gotten a chance to resolve this. I think I will have time to revisit this soon though.

          In response to your previous comments, I don't think it is a problem with basic authentication on the JIRA side, because that curl request does show that basic authentication is viable, and we have succeeded with basic authentication API calls using Postman. But I will try an OAuth call just to make sure. 

          Justin Duda added a comment - Hi, sorry for disappearing, I had to work on other things and haven't yet gotten a chance to resolve this. I think I will have time to revisit this soon though. In response to your previous comments, I don't think it is a problem with basic authentication on the JIRA side, because that curl request does show that basic authentication is viable, and we have succeeded with basic authentication API calls using Postman. But I will try an OAuth call just to make sure. 

          Justin Duda added a comment - - edited

          Hey nrayapati. So I need to update a custom field in JIRA issues, and it looks like this plugin is the only way to do it in the pipeline workflow/groovy, so I'm working to figure this out again. 

          I've also noticed that calling functions by default will use 'null' as the site, even though there is a configured site set up (unless JIRA_SITE needs to be set somewhere? I'm assuming that it should default to the site configured at plugin setup). Also, $env.JIRA_SITE is null. So maybe the groovy functions aren't seeing the plugin configurations, and that's why its not using the username and password in the configuration. Do you think that is possible?

          Also, I'm calling the functions within a Closure object, do you think that could be a problem? It's not directly wrapped in a stage like in most of the examples.

          Justin Duda added a comment - - edited Hey nrayapati . So I need to update a custom field in JIRA issues, and it looks like this plugin is the only way to do it in the pipeline workflow/groovy, so I'm working to figure this out again.  I've also noticed that calling functions by default will use 'null' as the site, even though there is a configured site set up (unless JIRA_SITE needs to be set somewhere? I'm assuming that it should default to the site configured at plugin setup). Also, $env.JIRA_SITE is null. So maybe the groovy functions aren't seeing the plugin configurations, and that's why its not using the username and password in the configuration. Do you think that is possible? Also, I'm calling the functions within a Closure object, do you think that could be a problem? It's not directly wrapped in a stage like in most of the examples.

          Naresh Rayapati added a comment - - edited

          is authentication problem solved? 

          site is mandatory unless it is configured as a global environment variable refer to the configuration documentation, https://jenkinsci.github.io/jira-steps-plugin/config.html#environment-variables

          Also refer one of the examples given on any step, have mentioned 3 types of example on each step to cover these global variables. 

          As soon as it is configured as global environment variable calling it anywhere shouldn't be a problem. 

          One difference is when setting site as a global variable or environment variable the code need to wrapped in node (thats when it will have access to environment variables) if we don't want to allocate node for these JIRA actions, I would send the site as a argument to the step. 

          Naresh Rayapati added a comment - - edited is authentication problem solved?  site is mandatory unless it is configured as a global environment variable refer to the configuration documentation, https://jenkinsci.github.io/jira-steps-plugin/config.html#environment-variables Also refer one of the examples given on any step, have mentioned 3 types of example on each step to cover these global variables.  As soon as it is configured as global environment variable calling it anywhere shouldn't be a problem.  One difference is when setting site as a global variable or environment variable the code need to wrapped in node (thats when it will have access to environment variables) if we don't want to allocate node for these JIRA actions, I would send the site as a argument to the step. 

          jdudatt Do you think, you need some help with this JIRA? otherwise I will close it. Thanks.

          Naresh Rayapati added a comment - jdudatt Do you think, you need some help with this JIRA? otherwise I will close it. Thanks.

          Naresh Rayapati added a comment - - edited

          Closing this Issue, please reopen it if this is still an issue.

          Naresh Rayapati added a comment - - edited Closing this Issue, please reopen it if this is still an issue.

          Kevin Darne added a comment - - edited

          Hi,

          Just for info, I got a similar issue and solved it just by using HTTPS protocol instead of HTTP for my JIRA server URL (=_=).
          JIRA server seems to ignore Authorization header over http, so all calls were performed as anonymous ('X-AUSERNAME: anonymous' in reply headers).

          getServerInfo() was returning success when configuring JIRA site, so it took me some time to realize one letter was missing in the url...

          Kevin Darne added a comment - - edited Hi, Just for info, I got a similar issue and solved it just by using HTTPS protocol instead of HTTP for my JIRA server URL (=_=). JIRA server seems to ignore Authorization header over http, so all calls were performed as anonymous ('X-AUSERNAME: anonymous' in reply headers). getServerInfo() was returning success when configuring JIRA site, so it took me some time to realize one letter was missing in the url...

          nick tan added a comment -

          thanks paldari, you saved my time, i got the same issue and fixed with 'https' protocol .

          nick tan added a comment - thanks paldari , you saved my time, i got the same issue and fixed with 'https' protocol .

            nrayapati Naresh Rayapati
            jdudatt Justin Duda
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: