TFS Post Build script executing twice - batch-file

I have a post build batch file being executed after a TFS build. It compiles an Inno Setup script and places the generated exe in a drop folder. It then tries to run that exe and install the application on the server. It runs the exe; however, this hangs the build.
The issue is, it seems to execute it twice. I can see 2 process running for the installer in task manager. If I execute the batch file manually, there are no issues - it's only when TFS executes it, I run into this problem.
Post Build Batch File
cd "C:\Program Files (x86)\Inno Setup 5"
iscc "%scriptDir%\Script.iss"
cd "C:\Deployment"
start Installer.exe /VERYSILENT
Any ideas would be greatly appreciated. Scratching my head with this.

From my findings, the post build script was NOT executing twice.
I believe the issue had something to do with permissions. The build service was being executed via the LocalService account which did not have permission to install the application. I THINK the build service tried to execute the installer but was denied and silently failed (and possibly tried again causing the additional installer process).
Solution: Set the Build Service to run under a different account with the permissions to install applications.

Related

i cant run mongo.exe from cmd

every time I run mongod.exe from cmd I get the following message on my screen
I'm a beginner in this so I really don't know what it means
I haven't seen anything on the web describing this
You have three questions.
Cannot run mongo.exe - See mongo.exe not installed in Version 6.0.0
Excessive output when you run mongod.exe
Install MongoDB as service. Create a configuration file (a default file should be created at C:\Program Files\MongoDB\Server\6.0\bin\mongod.cfg while installation) and create the service with
mongod.exe --install "C:\Program Files\MongoDB\Server\6.0\bin\mongod.cfg"
Then your MongoDB starts automatically at boot time.
I haven't seen anything describing the log format - See Log Messages

Azure Devops PowerShell Script Not Writing DACPAC Output

I'm attempting to execute a PowerShell script in Azure DevOps that creates a DACPAC file. The script completes successfully but no file shows up where it's supposed to show up. The script works properly when I run it via the PowerShell client.
The script is run inline. Here's the script:
& $(SqlPackagePath) /TargetFile:$(TargetDacPacFile1) /Action:Extract /SourceServerName:$(SqlServerName1) /SourceDatabaseName:$(DbName1) /SourceUser:$(SourceUser) /SourcePassword:$(SourcePassword)
note: not an answer
If anyone knows how one can view the $(agent.releaseDirectory) directory, I'd appreciate a tip
A lot of effort in Azure DevOps is running commands like this to work out where the hell your file is:
- task: CmdLine#2
displayName: Check Build.SourcesDirectory Path
inputs:
script: DIR $(Build.SourcesDirectory) /B /S
I resolved the issue. Apparently, Azure Pipelines doesn't have access to the file system AFAIK. I changed the target path from the local file system to $(agent.releaseDirectory)/$(TargetDacPacFile1). I was then able to pick up the DACPAC file in the next activity to deploy it.
If anyone knows how one can view the $(agent.releaseDirectory) directory, I'd appreciate a tip. Thx.

Running a bat file in Jenkins

I am trying to run a bat file to start a server as follows:
cd c:\...\bin
call asadmin start-domain
This should start the server. It works great with command prompt, but it is not working when I am using the same commands with Jenkins. It is a freestyle project.
When I run the build it says "attempting to the start domain..." and then completes the build with status "success", but the server is still not started.
I would be grateful, if someone could guide me in this regard.
Thank you in advance,
Fred

Why does this jenkins job never complete?

I have a windows 8 jenkins slave (really more than one) and I want to have a task which clones a mirror of a git repository if it doesn't exist and always fetches latest.
I've got this 'execute windows batch' step:
if not exist "server-reference" (
git clone --mirror git#ssh.com:something/somewhere.git server-reference
)
pushd server-reference
git fetch --all
popd
exit /B %ERRORLEVEL%
The console output for the job gets to this point
c:\jenkins\workspace\thing\server-reference>git fetch --all
Fetching origin
and never finishes
If I switch an exit above the fetch then I get the expected exit.
And if I run the batch file commands as the jenkins user on the windows box everything works as expected. So I (think I) know that the git fetch --all runs on the slave without prompting for input
How do I amend this script so that it completes when Jenkins runs it?
A number of things can cause this problem. Here are things that have worked for me in the past.
I know you stated this above, but just to double-check: Confirm that when you run git fetch --all manually on the slave machine, it doesn't prompt you for a password. If it does, Jenkins would get stuck on that step, so you'll need to set up an SSH keypair.
Make sure that you are calling C:\Program Files (x86)\Git\cmd\git.exe and not C:\Program Files (x86)\Git\bin\git.exe in Jenkins. The second one can cause this problem in certain versions of git.
On the slave machine, set the environment variable HOME to C:\users\[username], filling in your user's username. (For older OS's it was C:\Documents and Settings\[username].) Then recycle the Jenkins service and try again.
Double check that in Administrative Tools > Services, the Jenkins slave service "Log On As" is set to your user and the password is correct. If not, set those values, recycle the Jenkins service and try again.
If none of the above worked, try uninstalling and reinstalling git. And if you aren't using it, try installing the newest version of git.

Execute windows batch command from Jenkins fails but runs fine in cmd.exe

I am trying to run this command in jenkins after a MSbuild
xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E
Y: is a mapped network drive. This runs fine in cmd.exe but when trying to run it in Jenkins, I am getting the error Invalid drive specification.
Here is the output from jenkins:
Time Elapsed 00:00:04.03
[trunk] $ cmd /c call C:\Windows\TEMP\hudson3389873107474371072.bat
C:\Program Files (x86)\Jenkins\workspace\trunk>xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E
Invalid drive specification
0 File(s) copied
C:\Program Files (x86)\Jenkins\workspace\trunk>exit 4
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Any help would be appreciated.
I too had a similar issue once. Try granting the Jenkins service "Logon as This account" right under services.msc and make sure the account you type there is the same as the one you use for running cmd.exe.
These commands based on Java JAR files worked for me:
cmd
net use x: \\
xcopy "dist\" x:\ /Y
And that's it! I spent lot of time figure out this issue and nothing worked until I wrote CMD and NET USE!
Neither I didn't need to change permission on jenkins service nor use runas command.
But I must mention that everyone had read and write access to the network drive.
I had the same issue with my Windows Task running a batch file (I know it is not exactly same) where I tried to copy file to network location i.e. shared drive. I used the UNC path and mapped drive as well but the error was same. For me it was error number 4 - MS DOS error code.
The solution was to use net use command! Hope that it helps.
Easy fix for most things.
Make a batch command with what your trying to run, filename.bat with the command prompt text inside.
Make a normal windows shortcut for the batch command, edit the shortcuts advanced properties and check the "Run as admin" (tricky tricky).
Now run the filename.lnk shortcut from jenkins command line call, this will get you around all the jazz.
:)
The solution of adarshr (i.e., modifying the log on credentials of the service) has worked for me for a part of the problem: in my case, this allowed me to successfully check out a mercurial repository (using ssh protocol), which I could not do when using 'Local System account'.
However, I still have different behavior between running a command-line script or running the same script from a jenkins 'execute shell' script in the build section. In my case, I compile a Python extension. In Jenkins, I cannot import the extension (I don't see any error, but the execution simply stops, so I suspect it crashes).
If I uninstall the service and run the slave agent as a Java Web Start, I do get the same behavoir. It is a temporary fix for me, but it means that when I reboot the windows build machine, I have to manually re-start the Java Web Start application.
So -at least in my case- it is clear that this is a credential problem.
Credentials usage documentation: https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI
I've solved my issue with the CIFS plugin.
Faced similar issue and found two ways to solve.
Type 1:
Tell Jenkins about mapped drive.
1.Goto -> Manage Jenkins -> Script Console (Groovy Script).
2.Run below command
def mapdrive = "net use Y: \\\\copy_nework_address"
mapdrive.execute();
println "net use".execute().getText()
Type:2
1.Goto -> cmd -> run "net use" to know network address
xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Copy_Network_Address\Extraction_Zone\Jenkins\" /E
Conclusion:- I prefer 2nd types as after every restart i should run Groovy Script.

Resources