Run a batch job from Jenkins with the user who triggered the build - authentication

We are using Jenkins to start a C# program using parameters. The job is started manually from Jenkins. It's run from a Jenkins node on another server.
The problem is the C# program is started with the login specified on the node. I want it to run with the user who triggered the build.
I tried to use the Authorize Project plugin but with no luck. The node still uses it's own login when running the C# program.
I have seen other posts on this topic with a suggestion to make a node with the specified login. This won't help me since I want it to run with the user who triggered the build.

I found out that I needed only the user name in the C# program. So instead of starting it with the logged-in user I just passed the current Jenkin user as a parameter. To get the user name as an environment variable I installed the build user vars plugin.
The command in the Jenkins configuration was then set to:
program_name.exe %BUILD_USER%
This doesn't answer the question directly, but it solved my problem.

Related

JetBrains Rider: How to attach to elevated permissions process running locally?

I am using JetBrains Rider on Linux to debug some .NET core services. I have launched Rider without sudo permissions since my code source tree is all under my local user, but yet the installed services are running under root permissions.
Right now I'm in a predicament where in order to attach to the running processes, I have to launch a new Rider instance using sudo, but that then messes up the source code tree. Overall, this is a huge pain.
I would like to be able to attach to the elevated-permission service via an instance of Rider that is launched without sudo. I think the below is the way to do it: Run --> Attach to Remote Process, which brings up the below popup:
However, the problem with this popup is that if I click the arrow on root#localhost:22, then it shows no processes to attach to. Yet, the 4 processes are there that I would like to attach to (in the screenshot, they are 14949-14952). How can I get "no processes to attach to" to list the 4 processes in question? I have seen this done before by another developer, just think I'm missing something. Also, I'm 100% sure I know the root password.

Deployment from within IntelliJ IDEA

Deployments from IDEA are possible, e.g. I can connect to remote server and I can upload a package. The deployment process I have involves a little bit more than just deploying a file on server.
Once the file is uploaded I need to run certain commands to complete the deployment which mean I need to connect to the server and run those commands one by one and I am looking to do that through one click from the IntelliJ IDEA.
Is that possible?
This is how the project directory looks like:
This is how I am trying to setup deployment:
if you click on that little "Fix" button that's what I see
Even if I try to remove the unwanted entries they come back and never go away.
Finally this is what my project structure looks like in idea
Yes, you can use Remote SSH External tools. Make a script that will run your commands, deploy it to the server as well, then run this script remotely via a tool.
In the Run/Debug configuration Before Launch steps you can add your remote external tool to run automatically.
You can find some more details in my another answer.

E2E test passed the local run but failed in Jenkins (protractor and jasmine 2)

We have e2e test integrated with Jenkins system. For a few weeks this test successfully ran both, locally and from Jenkins (as a part of the build pipeline).
At the end of Sprint, I modified the script to reflect Sprint changes and made sure it passed locally. Then, I merged the changes with master. Now, e2e runs from Jenkins are failing 100% of the time, while when I locally connect to QA envs there is no problem.
The error I am getting is - Element is not clickable at point (x, y) which I cannot reproduce locally.
The server doesn't have a real screen so I cannot go out there and see what's going on. Resolutions are perfectly matching. I have other people running this test locally and there is no problem.
What could possibly cause these failures and how do I troubleshoot this problem?
Thanks for your help!
Its a question from 1000ft and pretty difficult to identify where exactly the issue could be but I listed down some probable causes/debugging tips that could help you
1.Whats your checkout strategy from source code repository? Check job workspace and it should have the most recent code and check if its indeed the latest one.
May be configure Job to always pick a new version instead of 'update'
2.Add a reporter based on the test framework you are using especially the ones which provide screenshots. Refer my blog for more details -
3.Check the stack trace of your error from Jenkins console report and verify the exact trigerring point

Microsoft Access automated build hangs at creation of .ACCDE

I'm attempting to automate the build of a source controlled MS Access application (it's only the front-end, the back-end is SQL Server). The Access client is published to the users via a simple C# console app via ClickOnce... It's in that console project that I'm also building the MS Access application via a custom msbuild tasks from this CodePlex library: https://buildmsaccessdb.codeplex.com/ (which is also mentinoed in another StackOverflow post on the subject). On my machine, it all works fine. The Access source code is compiled into an ACCDB, which is then converted into an ACCDE which is what gets included in the published app.
However, when I make it an automated build in TFS, it always stalls at the step where it converts the ACCDB to an ACCDE. I've tried a variety of ways for executing the "Make ACCDE" (SysCmd 603) command. I've tried it in powershell scripts, in VBA, etc... but it always seems to stall. Is that because the automated build process is not an interactive process and maybe the the SysCmd 603 needs to be ran interactively? If I stop the build and take a look at the ACCDB, everything is good. It compiles and can be manually compiled into an ACCDE... so it's not that the ACCDB isn't compilable.
I'd like to test it as an interactive TFS service but I don't control the service account it's running under.
Any tips on suggestions are welcome and thanks in advance! We have this whole automated build and release process up and nearly working except for this one piece!
I don't know much about the MSBuild task library, but from a quick look at the source it looks like it opens Access to run the tasks and interacts with a dialog box at one point. If that's the case you'll definitely need to run the build in interactive mode.
The fact that your build is hanging and not erroring out would also indicate this is the case.
Even though you don't control the service account, I would presume there's someone else in your organisation that does. I'd suggest you work with them and to try the build in interactive mode and ensure it works. If needed you could always set up a second build machine that runs in interactive mode, with the current build server remaining in "run as a service" mode.

Unable to get IIS Express server running in Jenkins

I'm trying to run Selenium tests utilizing an IISExpress server. I'm using the VSTest plugin to run my tests. Everything works fine locally in Visual Studio but when I run the tests in Jenkins the IISExpress process never starts. I even tried adding a Windows Batch Command step in Jenkins specifically for loading up the server, but even that doesn't seem to do anything. When I run Jenkins as a service that can interact with the desktop and I watch what its doing, I can see that Selenium loads up the browser but IISExpress just never starts. Any thoughts on this?
You should be able to launch IIS Express through command prompt by either
Explicitly providing the /path:"#PATH" and /port:"#PORT" command line arguments, and then invoking an asynchronous call to the IIS Express executable.
Your command in Jenkins should be something along the lines of:
start "YOUR_IIS_EXPRESS_EXE" /path:"PATH_TO_YOUR_APPLICATION" /port:"YOUR_APPLICATION_PORT"
Or by
Providing a value for the /config command line argument.
Whilst using this technique however, ensure that your application is the first entry in the application host.config file.
The Jenkins command should then be something similar to:
start "YOUR_IIS_EXPRESS_EXE" /config:"PATH_TO_YOUR_APPLICATIONHOST.CONFIG_FILE"