• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • tfs-plugin
    • None
    • Jenkins 2.89.3; TFS 2017 on premise

      I have setup a TFS release job that has two artifacts - one from Jenkins and one from TFS Build.  In the Jenkins "release" job, I have a post-build action to Trigger release in TFS.  The userid is set to DOMAIN\userid (substituting the actual userid and Domain) and the correct password.  This user has admin rights in TFS and for the TFS Release job.  I get the below error.
      ERROR: Failed to trigger release.%n
      hudson.plugins.tfs.rm.ReleaseManagementException: hudson.plugins.tfs.rm.ReleaseManagementException: Error occurred.%nStatus: 401%nResponse:
      <!DOCTYPE html>
      <html>
      <head>
      <title>TF400813: Resource not available for anonymous access. Client authentication required. - Microsoft Team Foundation Server</title>

          [JENKINS-50267] Trigger release in TFS failing with TF400813

          Are you using your actual password for the account?  Use a personal access token.  https://docs.microsoft.com/en-us/vsts/accounts/use-personal-access-tokens-to-authenticate?view=vsts 

          Brian Cristante added a comment - Are you using your actual password for the account?  Use a personal access token.  https://docs.microsoft.com/en-us/vsts/accounts/use-personal-access-tokens-to-authenticate?view=vsts  

          Michel Calvin added a comment -

          Thank you.  That fixed the access issue and the Release is kicking off.  Not sure if you can help with this, but when the release job tries to download the Jenkins artifact I get an error (see below).  Creating and deploying the release manually from TFS works successfully.  The download of the artifact only fails when it is kicked off by the Jenkins job. 

          2018-03-28T23:09:45.6989288Z Received Jenkins Artifact Details
          2018-03-28T23:09:45.6989288Z Job Name: TFS Request Automation Test
          2018-03-28T23:09:45.6989288Z BuildId: 457
          2018-03-28T23:09:45.9284470Z An error occurred during download: Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.ArtifactDownloadException: Jenkins build 457 is invalid.
             at Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.JenkinsArtifact.<DownloadAsync>d__6.MoveNext()
          — End of stack trace from previous location where exception was thrown —
             at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
             at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
             at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseJobExtension.<>c_DisplayClass29_2.<<DownloadArtifacts>b_2>d.MoveNext()
          — End of stack trace from previous location where exception was thrown —
             at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
             at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
             at Microsoft.VisualStudio.Services.Agent.Worker.Release.RetryExecutor.<ExecuteAsync>d__20.MoveNext()
          2018-03-28T23:09:45.9374489Z ##[error]Jenkins build 457 is invalid.

           

           

          Michel Calvin added a comment - Thank you.  That fixed the access issue and the Release is kicking off.  Not sure if you can help with this, but when the release job tries to download the Jenkins artifact I get an error (see below).  Creating and deploying the release manually from TFS works successfully.  The download of the artifact only fails when it is kicked off by the Jenkins job.  2018-03-28T23:09:45.6989288Z Received Jenkins Artifact Details 2018-03-28T23:09:45.6989288Z Job Name: TFS Request Automation Test 2018-03-28T23:09:45.6989288Z BuildId: 457 2018-03-28T23:09:45.9284470Z An error occurred during download: Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.ArtifactDownloadException: Jenkins build 457 is invalid.    at Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.JenkinsArtifact.<DownloadAsync>d__6.MoveNext() — End of stack trace from previous location where exception was thrown —    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseJobExtension.<>c_ DisplayClass29_2.<<DownloadArtifacts>b _2>d.MoveNext() — End of stack trace from previous location where exception was thrown —    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)    at Microsoft.VisualStudio.Services.Agent.Worker.Release.RetryExecutor.<ExecuteAsync>d__20.MoveNext() 2018-03-28T23:09:45.9374489Z ## [error] Jenkins build 457 is invalid.    

          I'm unclear on what your setup is.  This is my understanding so far:

          1. You have two builds, a Jenkins build and a TFS build
          2. You have a single TFS release definition which consumes build artifacts from both builds and is triggered by successful completion of the Jenkins build

          Is that correct?

          Brian Cristante added a comment - I'm unclear on what your setup is.  This is my understanding so far: You have two builds, a Jenkins build and a TFS build You have a single TFS release definition which consumes build artifacts from both builds and is triggered by successful completion of the Jenkins build Is that correct?

          Michel Calvin added a comment -

          Yes, that is correct.  On successful completion of the Jenkins build, the TFS release definition is created and based on the conditions of the release a deploy is executed after the release is successfully created.  The release definition tries to download the artifacts (Jenkins is primary) and fails with the error I provided previously.  When I create the release from TFS, just to see if the error happens from Microsoft, I am prompted for the Jenkins build I want to pull artifacts from, the release is created and the deploy executes and completes successfully.  The artifacts from Jenkins and TFS are downloaded with no errors and the remaining steps complete.

           

          Michel Calvin added a comment - Yes, that is correct.  On successful completion of the Jenkins build, the TFS release definition is created and based on the conditions of the release a deploy is executed after the release is successfully created.  The release definition tries to download the artifacts (Jenkins is primary) and fails with the error I provided previously.  When I create the release from TFS, just to see if the error happens from Microsoft, I am prompted for the Jenkins build I want to pull artifacts from, the release is created and the deploy executes and completes successfully.  The artifacts from Jenkins and TFS are downloaded with no errors and the remaining steps complete.  

          Can you attach the full logs from the release agent?  The logs from the Jenkins build would be helpful as well.

          Brian Cristante added a comment - Can you attach the full logs from the release agent?  The logs from the Jenkins build would be helpful as well.

          Michel Calvin added a comment -

          Michel Calvin added a comment - Logs attached. Release.zip JenkinsLogs.txt

          Thanks for the logs.  It looks like the Jenkins build is working fine now and that this is a problem with the TFS release.

          I would recommend taking this question about consuming artifacts to Developer Community: https://developercommunity.visualstudio.com/spaces/21/index.html 

          The only thing I can think of is to make sure there isn't any kind of firewall in between your TFS release agent and your Jenkins server, but from the error message that doesn't sound like the problem.

          Since we fixed the original issue with the Jenkins TFS plugin, I'm going to close this bug.

          Brian Cristante added a comment - Thanks for the logs.  It looks like the Jenkins build is working fine now and that this is a problem with the TFS release. I would recommend taking this question about consuming artifacts to Developer Community: https://developercommunity.visualstudio.com/spaces/21/index.html   The only thing I can think of is to make sure there isn't any kind of firewall in between your TFS release agent and your Jenkins server, but from the error message that doesn't sound like the problem. Since we fixed the original issue with the Jenkins TFS plugin, I'm going to close this bug.

            redsolo redsolo
            calvinmichel Michel Calvin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: