Jenkisn does not run SQL on test project

Good morning guys,

I’m having a problem with Jenkins, I have a job that runs API Rest tests, the test makes a query in the SQL database to get an id, but Jenkins stops in this part, it doesn’t show any error but it doesn’t run.

I’m running the local Jenkins.
When I run the same test on the same machine in VS Code, the test runs normally.

thanks

This is absolutely 100% not a jenkins problem. Your _retornoBanco is undefined, which is returned by the previous statement.

I’m not sure what you mean by doesn’t run and show an error. The first section of your screenshot is an error that needs fixing.

Good afternoon,

yes the return is undefined, only when I run the test by Jenkins.

When I run the same test, on the same machine, opening the project by VS Code, the test passes successfully.

The problem is when I run only by Jenkins which returns undefenid

It seems to me that Jenkins lacks something to execute the line of code that contains SQL execution

probably. But you need to figure out what that is. Probably an ENV variable or something in a config file. Maybe even a different version of node on your build agent. You need to figure out whats different. Probably by tracing the code. Jenkins doesn’t do anything to your code, just runs the commands you tell it to.

That’s what I don’t understand, because it’s the same machine, the same branch, the same code, and only in Jenkins does that happen.

I don’t know the way to identify the problem, do you need a plugin?

Without access to your build agent (which I don’t want) and without access to your code. There’s nothing we as external people can do.

My recommendation is to go look at what that function that is returning the variable does, and see what its doing. Maybe its talking to the wrong port, or the server is running differently. Or the server never started up.

Or in your pipeline, run printenv in linux, set in windows, and see what environmental variables are set, and compare them with your local environment. Maybe node -v as well to see.

Most simple guess: The sql access is not granted for the jenkins user.

Always remember: a job in jenkins typically runs as another user, even if you run jenkins on the same machine and you always need to configure credentials for external systems. How to that in your case is hard to tell as we do not know yout setup/code.