Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JenkinsQueueJob does not work for Jenkins Pipeline Jobs #3135

Closed
tkp1n opened this issue Nov 22, 2016 · 14 comments
Closed

JenkinsQueueJob does not work for Jenkins Pipeline Jobs #3135

tkp1n opened this issue Nov 22, 2016 · 14 comments

Comments

@tkp1n
Copy link

tkp1n commented Nov 22, 2016

Jenkins Jobs of type Pipeline cannot be triggered from VSTS.
Example result:

2016-11-22T07:26:13.1483481Z fa71031c-a3fc-4a7c-ba79-bd0c913f2c3d exists true
2016-11-22T07:26:14.0550576Z Job creation failed.
2016-11-22T07:26:14.0580575Z HttpResponse.statusCode=400
2016-11-22T07:26:14.0580575Z HttpResponse.statusMessage=Bad Request
2016-11-22T07:26:14.0580575Z HttpResponse=
2016-11-22T07:26:14.0590577Z {"statusCode":400,"body":"java.lang.IllegalArgumentException: Project not found\n\tat hudson.plugins.tfs.TeamBuildEndpoint.innerDispatch(TeamBuildEndpoint.java:208)\n\tat hudson.plugins.tfs.TeamBuildEndpoint.dispatch(TeamBuildEndpoint.java:159)\n\tat hudson.plugins.tfs.TeamBuildEndpoint.doBuild(TeamBuildEndpoint.java:237)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.lang.reflect.Method.invoke(Method.java:498)\n\tat org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:324)\n\tat org.kohsuke.stapler.Function.bindAndInvoke(Function.java:167)\n\tat org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:100)\n\tat org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124)\n\tat org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)\n\tat org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)\n\tat org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)\n\tat org.kohsuke.stapler.MetaClass$11.dispatch(MetaClass.java:380)\n\tat org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)\n\tat org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)\n\tat org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)\n\tat org.kohsuke.stapler.Stapler.service(Stapler.java:238)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)\n\tat hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)\n\tat hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:80)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)\n\tat hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat jenkins.security.BasicHeaderProcessor.success(BasicHeaderProcessor.java:140)\n\tat jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:82)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)\n\tat hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)\n\tat hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)\n\tat hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)\n\tat hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)\n\tat org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)\n\tat org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:499)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)\n\tat org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)\n\tat winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\n","headers":{"date":"Tue, 22 Nov 2016 07:26:14 GMT","x-content-type-options":"nosniff","x-error-message":"Project not found","content-type":"text/plain;charset=UTF-8","connection":"close","server":"Jetty(9.2.z-SNAPSHOT)"},"request":{"uri":{"protocol":"http:","slashes":true,"auth":null,"host":"xxx","port":"xxx","hostname":"xxx","hash":null,"search":"?delay=0sec","query":"delay=0sec","pathname":"xxx","path":"xxx","href":"xxx"},"method":"POST","headers":{"Jenkins-Crumb":"xxx","content-type":"application/x-www-form-urlencoded","content-length":xxx,"authorization":"xxx"}}}

(Personal information replaced with xxx)

@davidstaheli
Copy link
Contributor

Hi @tkp1n,

Apologies for the trouble. Jenkins pipelines are supported, so we would appreciate your help in troubleshooting why Jenkins is responding with HTTP 400 ("Project not found") in your case. It appears to be happening on line 208 of the TFS plugin.

Can you please reply with the name of the job you are trying to queue, and the versions of Jenkins and the TFS Plugin you are running?

Thank you,
David

@tkp1n
Copy link
Author

tkp1n commented Nov 23, 2016

Name of the Pipeline Job (not working): "Atrak"
(I then created a "normal" Job with the name "Atrak-VSTS" and that worked..)

Jenkins Version: 2.19.3
Team Foundation Server Plug-in Version: 5.2.1

@yacaovsnc
Copy link
Member

It appears the "Pipeline" type in Jenkins 2.19.x is not yet supported in TFS plugin -- it's a new type introduced in the workflow plugin and the current TFS plugin does not have a dependency on it, hence it can't support this type yet. We need to be careful about introduce this dependency since it may break backward compatibility with older servers.

@tkp1n
Copy link
Author

tkp1n commented Dec 22, 2016

I see, to bad.. since this new type is really a big plus for building more complex projects.
Let me know if I could help in any way!

@mgamsjager
Copy link

We have to same issue. We are moving to TFS and most of our Jenkins projects are Multibranch projects

@davidstaheli
Copy link
Contributor

Just to be clear, this is a limitation of the TFS Plugin for Jenkins. We should add support in that repo.

@davidstaheli
Copy link
Contributor

I logged this issue against the TFS Plugin repository:
https://issues.jenkins-ci.org/browse/JENKINS-40774

@yacaovsnc
Copy link
Member

TFS plugin 5.3.3 has been released and it supports triggering Pipeline and Multibranch job now.

To trigger a Multibranch job, please enter "Jobname/BranchName" as the jobname in the task.

@ricardf
Copy link

ricardf commented Oct 1, 2018

@yacaovsnc

Is there a way that the queue job from tfs will execute the corresponding branch into jenkins?

@bbarman4u
Copy link

bbarman4u commented Jul 3, 2019

I still keep getting http 400 while queuing the job ! Can any one provide a working screenshot for this ?
@yacaovsnc

@rakeshsvr18
Copy link

Does anyone has a solution to the above ? I am still getting a 400 while queuing the job for a Multibranch job. @yacaovsnc Should we give the Full url of the job or just the "Jobname/BranchName". And how can we specify the branch name as we need to build all branches in case of Multibranch setup ?

@stefaneicher
Copy link

I have also the setup that I configured Jenkins as a multibranch pipeline.
So this Jenkins setup automatically runs an existing job if an update the branch happens AND also creates jobs for newly created branches automatically.

This works fine but not is want to trigger the build for any dynamic created branch by tfs.
With this setup, I can control everything by git from tfs. What I now want to do is to tell TFS that is shall trigger my Jenkins multibranch build for whatever branch has been changed or created.

Here my config
Tigger:
image

Jenkins Queue Job:
image

This dynamically runs my changed branches but If I created a new branch for which there exists no job yet it fails with
{"statusCode":400,"body":"java.lang.IllegalArgumentException ...

How should I now adapt my setup?

@ricardf you may configure the branch-like I did with $(Build.SourceBranchName)

An other problem is that the $(Build.SourceBranchName) variable for a branch called "feature/f1" gets resolved as "f1" in TFS and not "feature/f1" this is in my opinion simply wrong. I therefore had to change the branch name to featurte_f1 that $(Build.SourceBranchName) contains the correct information. To log that run cmd.exe with the argument /k set.

see also: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

@clD11
Copy link

clD11 commented Feb 19, 2020

The issue as mentioned by @stefaneicher is still not resolved -

When create new branches dynamically if no job exists it fails.

This dynamically runs my changed branches but If I created a new branch for which there exists no job yet it fails with
{"statusCode":400,"body":"java.lang.IllegalArgumentException ...

When are we gong to see this fixed?

@atigm
Copy link

atigm commented Oct 19, 2020

I have the same probem,

On Jenkins :

  • I activated Enable Push Trigger for all jobs and Enable Team Status for all jobs
  • I create project named WabApp

On Azure devops :

  • I have an application on Repos (Jenkinsfile + azure-pipelines.yml + sources)
  • I configure service connection to Jenkins and it's work fine

When A push change, I get this error :

Job creation failed.
HttpResponse.statusCode=400
HttpResponse.statusMessage=Bad Request
java.lang.IllegalArgumentException: Job: WabApp not found
	at hudson.plugins.tfs.TeamBuildEndpoint.getJob(TeamBuildEndpoint.java:269)
	at hudson.plugins.tfs.TeamBuildEndpoint.innerDispatch(TeamBuildEndpoint.java:292)

azure-pipeline.yml

trigger:
- master
- develop
- feature/*
- tech/*
- hotfix/*

pool:
  vmImage: 'ubuntu-latest'

steps:
- script: |
    echo Run Multibrach pipeline.
  displayName: 'Run Multibrach pipeline'

- task: JenkinsQueueJob@2
  inputs:
    serverEndpoint: 'jenkins'
    jobName: 'WabApp'
    isMultibranchJob: true
    multibranchPipelineBranch: $(Build.SourceBranchName)
    captureConsole: true
    capturePipeline: true
    isParameterizedJob: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants