How to get the currently logged in windows user with NAnt - authentication

I have a NAnt script that does a build and deployment of an ASP.Net application.
This lives on a remote machine that many people log into to perform builds.
(this is not automated for various reasons that are irrelevant)
Upon success or failure of the Nant script, I have an email being sent out to a team distribution list, stating that the build was successful or failed.
I would like to be able to list the name of the user who logged into the remote machine to run the build script in the text of the email.
Is this possible in NAnt?
I am using the standard NAnt <mail> task to do the email.

Check environment::get-user-name() function. It gets the user name of the person who started the current thread (nant process).
<mail
...
subject="Build run by ${environment::get-user-name()}"
...
</mail>

Related

Where is the.cs files when a script task is run from the SSISDB using the agent?

I have an SSIS job that contains a script task.
There is also a connection to another server within the package that can only be executed accessed by a specific user and the agent cannot be given read rights to the other server.
So the solution to this is have the SQL job be run as the required user.
The problem with this is this user does not have full control over the folder/file where the script task will be temporarily located while the code runs so I get a failure on the script task but if I run it in visual studio or with the normal agent account the script task executes successfully.
I have tried giving the user access to all major drives on the server but this has not solved the problem
Is the script doing something on the folder?
Or does it just need permission to execute script?
I would anyway advise you to implement error handling in script:
https://learn.microsoft.com/en-us/sql/integration-services/extending-packages-scripting/task/logging-in-the-script-task?view=sql-server-2017
Make sure it works in visual studio, so that when you get that error you are sure that the error is caused by permissions/environment.
You could also take a look at this article:
article

Unable to run a test from MTM - Config issue

I have set up a Test Controller and Test Agent running in separate machines and they are able to communicate with each other.
When I try to run the test from MTM (Selenium Tests), the test failed with the below error message
(QTController.exe, PID 1104, Thread 15) Could not use lab service account to access the build directory.
Failure: Network path does not exist or is not accesible using following user:
https://mydevelopment.visualstudio.com/defaultcollection/c2f372df-8c45-487a-9b51-4ced6e8f6037/_apis/build/builds/969/artifacts?artifactName=drop&%24format=zip
using MYDEV\timothy.alex. Error Code: 67
(QTController.exe, PID 1104, Thread 15) TcmRunner: Error starting the test run: The build directory of the test run either does not exist or access permission is required..
This clearly mentions that the error is because of access issue. But when I try downloading the build from the url mentioned in the error log using the same credentials mentioned in the ERROR log, I am able to download the drop zip file.
Is there any thing I am missing in the set up. Any help would be really really great.
It looks like you're using the new task-based build system. You can't run automated tests from a task-based build from MTM at present -- you have to use the older XAML build system for that.

Running a program at login as admin

I have a program I wrote in Visual Basic Express 2013 to put a classification banner at the top of the screen. I set up a scheduled task using ngen.exe which makes it run at login. The problem is that it doesn't run as admin so any non-privileged user can kill the task.
This program is to replace another program called Netbanner because there are a few issues with Netbanner. The program I wrote resolves all of these issues except for the admin issue. Netbanner is implemented exactly the same way (ngen.exe) but it won't let a non-privileged user kill the task.
I don't know if it is something in the program itself or I missed something in the deployment process.
This is the command used to deploy Netbanner which I duplicated to deploy mine:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\ngen.exe install "C:\Program Files\Microsoft\NetBanner\NetBanner.exe"
Also, these are the files in C:\Program Files\Microsoft\NetBanner:
NetBanner.exe
NetBanner.InstallState
NetBanner.pdb
NetBannerSchTask.xml
Any ideas?
Thanks.
You could try to go into the properties->Compatibility->Run this program as an administrator for the application.
Alternatively, you could do the same thing for a batch file that you can schedule to run on startup.

SSIS Execute Process Task Can't Find executable

I am using the 7zip standalone .exe to unzip a file. I am using the Execute Process task for this. I have tested this over and over again on multiple machines and I know it works (at least in debug mode/visual studio). I have uploaded this package the server. I have created a job that calls said package from the Package Store. The package is not able to find the .exe no matter where I put it.
My first thought was to put the .exe on the C:\ drive, which failed. I have also failed in my attempts to place the .exe on a network location that the account the package is running under has full control over.
Basically, has anybody else had issues getting the Execute Process Task to find an executable when the package is uploaded to the server?
The error message is
Can't find 7za.exe in directory C:\7zip
I'll risk a downvote for being wrong, but I believe you have a permission issue.
You say it runs fine on other servers from BIDS, try it without BIDS. Call it from a command-line on a box that it works on.
dtexec.exe /file C:\HereComesTheUnzipper.dtsx
If that works, then repeat the step on the troublesome server. RDC into the box and try again
dtexec.exe /ser localhost /sq HereComesTheUnzipper
If that still works, then you are looking at an issue with the job. What account is the SQL Agent service running as? Is the SSIS job step running as a particular set of credentials? If so, is it a SQL Server login (which wouldn't map to anything on the physical box)? Regardless of what your answer is, the resolution will be to ensure the account has access to
7z.exe
whatever scratch area 7zip may use while unpacking files (I assume %temp%)
the output folder (C:\bin\7z.exe -e e:\data\MyThing.7z)

Can I bypass Gated Check-In build after checking a file in during a separate build process? TFS 2010

I have 2 build definitions set up for a solution, 1 is a nightly build that is triggered every night and the other is a Gated Check-In build that will trigger when developers try to check new changes into source control. The nightly build is using a custom template that increases assembly versions using method that has been slightly modified from the Ewald Hoffman method. When a file is checked in via the custom activity to check files in, i get the build error:
Your check-in could not be completed because it affects the following
gated build definitions \Project\GatedBuld. To complete your check-in
you will need to queue a build of the shelveset
Gated_2011-11-08_09.31.42.6934;DOMAIN\TFSBuildAccount.
At present I have not been able to find a way to bypass this gated check-in build (CI builds are prevented using the *NO_CI* check in comment).
I have tried setting the "Override check-in validation by build" permission for the build service account (via Security for the gated build), but as far as I know this will only prevent the gated build when checking code in manually (via a check box presented in the Gated Check-in dialog). What I'm looking for is a way to bypass a gated build when checking changes in automatically
Any suggestions?
As always, thanks for any help in advance
When you checkin your changes programmatically, you can create a WorkspaceCheckInParameters object and set its OverrideGatedCheckIn property to true. The following code would bypass gated checkin (and also CI):
var pendingChanges = workspace.GetPendingChanges();
if (pendingChanges.Any())
{
WorkspaceCheckInParameters parameters = new WorkspaceCheckInParameters(pendingChanges, BuildCommonUtil.NoCICheckInComment)
{
OverrideGatedCheckIn = true,
};
workspace.CheckIn(parameters);
}
Note that you need to grant the permission to bypass gated checkin on the account that performs the checkin for all affected build definitions. In this case, it is the build service account of the Nightly build.
I had written the Assembly Version update code in Powershell and could not find the slimier code "OverrideGatedCheckIn = true" for Powershell and all I did was moving assembly version files (SharedAssembly.vb & SharedAssembly.cs) to a folder called SharedAssembly and excluding them to considering for the GatedCheck-In process.