TeamCity: How to show parameters in the history - teamcity

I have 3 servers for PROD, with the same deployment build configuration, I choose which server to deploy depending on a build parameter.
The issue is that reviewing the history you can't check which environment are you deploying.
I wonder if it's possible one of this solutions:
- Show parameters in the history of a build
- Autotag a build with parameters
I hope I had explained well enough.
Thanks in advance

You can accomplish this with a Command Line build step that echoes the relevant parameters to the build log. For a Windows-based agent, you could do something like:
Run: Executable with parameters
Command Executable: echo
Command Parameters: Deployed to server %your.server.host%
This would simply add a line to the build log that reads, Deployed to server FOO
Autotagging would be pretty cool, but I don't know of a way to do that.

Related

Error Raised Only When Using Jenkins Pipeline

I am trying to setup a Jenkins pipeline using scripted pipeline with a windows 2019 server, however I ran into this error while trying to build
> webpack --config ./config/webpack-cli-prod.config.js
C:\myProject\node_modules\webpack\lib\javascript\JavascriptModulesPlugin.js:143
throw new TypeError(
^
TypeError: The 'compilation' argument must be an instance of Compilation
at Function.getCompilationHooks (C:\myProject\node_modules\webpack\lib\javascript\JavascriptModulesPlugin.js:143:10)
at SourceMapDevToolModuleOptionsPlugin.apply (C:\myProject\node_modules\webpack\lib\SourceMapDevToolModuleOptionsPlugin.js:50:27)
at C:\myProject\node_modules\webpack\lib\SourceMapDevToolPlugin.js:163:53
at Hook.eval [as call] (eval at create (C:\myProject\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:100:1)
at Hook.CALL_DELEGATE [as _call] (C:\myProject\node_modules\tapable\lib\Hook.js:14:14)
at Compiler.newCompilation (C:\myProject\node_modules\webpack\lib\Compiler.js:1122:26)
at C:\myProject\node_modules\webpack\lib\Compiler.js:1166:29
at Hook.eval [as callAsync] (eval at create (C:\myProject\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\myProject\node_modules\tapable\lib\Hook.js:18:14)
at Compiler.compile (C:\myProject\node_modules\webpack\lib\Compiler.js:1161:28)
I tried to run same command/step using freestyle Jenkins job, and it works without this error.
I tried to run the same command on the Jenkins agent locally, and it works without this error.
I looked up on google, and came across this link here, I tried to use newer version of html-webpack-plugin, and we also tried to build without the plugin. All come to the same result, that the error would occur only when running from Jenkins scripted pipeline.
I also tried with a different server, while keeping the same agent and job configuration, and I also get the same error.
The version of npm is 8.11.0, the node version is 16.16.0. The agent is connected through running the agent.jar file from the agent.
The only difference I see between the freestyle job and the scripted pipeline job is the freestyle job appears to be run as SYSTEM by the Jenkins server, whereas the pipeline job is probably run with lower privilege (I am not entirely sure though). I saw also this post, where it says
in the Freestyle job everything is executed in the agent, but for the Scripted Pipeline Job, the pipeline code is translated in the controller to atomic commands that are sent to the agents.
But I have no idea how to make the scripted pipeline job run just like the freestyle job.
On one hand, it appears to have to do with webpack, and on the other it appears to be related to Jenkins since running freestyle and locally on the server is without errors.
This is how my Jenkins scripted pipeline looks like (with sensitive information removed)
node("My-Server"){
dir("C:\\MyProject"){
stage('Pre-Test Build Client (Web)') {
dir("aFolder"){
bat 'npm run build-all-prod' // This is the script that invoke the webpack build command
}
}
}
}
I have run out of options, and do not where to go from here, and I couldn't find any more information on google that would be helpful. Any help here would be really appreciated. Thank you.
I'm not sure if jenkins creates the same environment variables, and command line tools (you can configure some on the node's configuration page). I would check if the node's environment variables and tools are the same in freestyle vs pipeline job by running something like this in each job, and comparing the output:
bat 'echo %PATH%'
bat 'which webpack'
bat 'npm list webpack'
Another thing worth checking is whether you're using batch script in both jobs, and not eg shell in freestyle.
Lastly I found a gh issue whith the same error as you, caused by having 2 different installations of webpack, one on v5. May be worth looking into, if everything else fails.

Nagios calling 'mvn test' in a project returns a error, but without details

I have a command defined as:
define command {
command_name xyz_minimal_check
command_line mvn --global-settings=(dir)/settings.xml -f (proj)/pom.xml -Dtest=ThingTest#testThing test
}
and a service defined to call this command. When it runs, I see:
[ERROR] Error executing Maven.
But I do not see any details in any log. Where might these be? I am sure there are some things I need to set up or some environment variables I have to provide to the command that nagios is running, but I cannot tell what they are. I have looked in the usual logs and see nothing specific to this service.
This is running on an Ubuntu 14.04 system. The usual ping and http services in nagios are working fine.
Well, the only place I can see the output of my command is in the web interface itself. Click on the service name and the output is in the description of the service there. It seems very strange that nothing goes into var/nagios.log or any other log file.....
And once I saw my output, I could see my errors. The issue was that I had to make it possible for the nagios user to run the "mvn test". My default, the permissions prevent this. The easiest way to do this is to create a directory owned by the nagios user, give it its own copy of the project, and give it its own .m2 directory. Then it will work.

How to check Mesos Master?

I'm new to Mesos. I would like to know how do I know whether Mesos master is set up correctly in the node?
I have follow the set up given by http://mesos.apache.org/gettingstarted/
I am unable to run the following command:
Comment: Start mesos master (Ensure work directory exists and has proper permissions).
$ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
but it shown error given:
./bin/mesos-master.sh: line 24: /home/user/mesos-0.20.0/build/src/mesos-master: No such file or directory
What ways should I proceed?
First, a few questions to help us debug your build:
Did the mesos build (make) complete successfully, and did make check pass all the tests?
If /home/user/mesos-0.20.0/build/src/mesos-master does exist, do you have execute permissions on it?
Are you running ./bin/mesos-master.sh from within /home/user/mesos-0.20.0/build/, or did you move the directory elsewhere?
If this is your first attempt at Mesos and you just want to run it and try it out (rather than fix bugs and develop features for it). I would recommend using a pre-built or cloud-deployed version of Mesos, rather than trying to build it yourself. See:
http://mesosphere.com/downloads/
http://mesosphere.com/downloads/details/index.html#apache-mesos
I'd suggest to follow Mesos Getting Started documentation.
After your system requirements are satisfied, following the section:
System Requirements
Once you reach the following section:
Building Mesos
when you execute the make without disabling verbosity, ensure that all process completed successfully. If it stops (e.g. tipically for proxy related issues) try to fix it accordingly or otherwise post your stack somewhere and I would be happy to help (if I can).
Unfortunately, running make check could not reveal the problem sometimes.
Have you run the make check command ? It is said in the documentation that the binaries will only be available after running the make checkcommand.Ì faced the same issue and it was because i didn't run that command.

Is it possible to get the raw build log from a TeamCity build?

Is it possible to get the raw build log from a TeamCity build? I've written a custom test runner that gets run as a commandline build step and reports test results back by printing ##teamcity... lines to stdout. The build log from TeamCity seems to be stripping these out when it recognises them. I'd like to see the raw output to help debug my test runner.
Update:
Apparently this simply isn't possible. neverov (I assume Dimitry Neverov of JetBrains?) has explained this and given a workaround so I've accepted his answer.
You can see the raw output from the build agent by looking in the agents /logs directory. This shows the unparsed data that is being hidden on the build output shown in the TeamCity console.
For example c:\TeamCity-Agent\logs\teamcity-build.log.
You can download it by clicking "Download full build log" on build log page.
I couldn't quite tell if this is what you were talking about when you refer to ##teamcity... lines in your question, but this is what I'm currently doing for command-line build steps (which is currently all I do):
##teamcity[testStarted name='dummyTestName' captureStandardOutput='true']
echo "Do your command-line build steps here."
##teamcity[testFinished name='dummyTestName']
It's sort of a hacky workaround, but it will result in stdout/stderr being displayed on the build log page in the TeamCity web UI.
I see that this question was asked long time ago (almost 10 years ago) but nothing changed in TeamCity.
I faced similar issue with test reporter and found a way to get raw log without connecting to build agent and getting it from there (it may be difficult). My solution does not cover the whole build log, but can be helpful when step is run via custom script in Build Steps.
So the solution is to add | tee e2e_raw.log into required build step script. For example we run tests in Docker by running docker-compose command:
tee will duplicate all the output into the file. Original output will be the same and will be parsed by TeamCity as usual.
You should also add a line into artifacts field to make build able to collect newly created artifact (Build General settings):
After that you will see a new archive in artifacts tab with raw log for this build step:
Great answers here before me. I would add that your TeamCity master holds log files for the builds, and you can get them on the command line.
Have a look in <TeamCity Data Directory>/system/artifacts/<project ID>/<build configuration name>/<internal_build_id>/.teamcity/logs.
This mattered to me because
The logs on the TeamCity agents were getting removed after a day or so, but the logs on the master were still available.
I wanted to grep them on the machine itself without having to download multiple, sizeable log files or use my web browser to make multiple page views.
There's an option on the build log to see 'detailed / verbose' - it shows all the service messages. I've seen it since TC9.

How do I troubleshoot when VSDBCMD does not deploy, but shows no errors?

I am trying to use VSDBCMD.exe (Visual Studio 2010 version) to deploy the output of a database project. I am including the /dd:+ switch in my command line. Every time I run the command, I get one message:
TSD00566 Deployment script generated to:
C:\Deploy\SqlServerDB.txt
There are no errors, but the deployment script is not executed and no deployment happens. I do not have the /Quiet switch turned on.
I have tried both specifying all parameters on the command line and using the .deploymentmanifest file. I get the same results either way: a script file is generated, but not executed. No schema changes are deployed.
I do know that my connection string is correct, because the deployment script that is generated is valid (and even references file paths that only exist on the target SQL server).
My current command line (as in, most recent attempt) is
vsdbcmd.exe
/a:Deploy
/cs:"Data Source=[the correct server];Integrated Security=True;Pooling=False;Initial Catalog=[the correct database]"
/Quiet-
/dd:+
/p:TargetDatabase="[the correct database]"
/dsp:Sql
/Model:"C:\[output path]\SqlServerDB.dbschema"
Can you please help me figure out how to troubleshoot this command, since I am not getting any error messages or useful output?
When VSDBCMD generates a delta script and detects that there are no changes between the database project and the target database, it does not execute the deployment step.
However, it also does not display any message indicating why it id not deploy. So, there were no errors (ergo no error messages) but it did not deploy because the source scripts were identical to the destination database after the first time we ran the command.
It would be nice to have some kind of message indicating "no changes to deploy," but at least I know now that it is working as designed, and that there was no deployment necessary.

Resources