Teamcity cli step fails in continuous build while works manually - macos

I have ported my project build from buildbot to teamcity and it now fails on a command line step where I call a shell script that:
1) launches the macdeployqt qt utility to codesign the built app and then
2) tries to notarize the app.
I always get a sigsegv during the launch of macdeployqt
Obviously launching the script manually on the same machine and folder works as expected.

The problem was on my side, a JetBrains support staff stated that command-line runner is just calling the script as it is and not modifying any environment. It turned out that the script was failing because there was a double / in a path.

Related

Is it possible to run an Xcode Build Phase Script when running xcodebuild from the command line?

I have a build phase Run Script in my Xcode project that is required for ensuring the module bundle is up to date. The script runs when actions are executed through the Xcode GUI, and the Swift Package is able to build and run tests successfully. But when I try to run xcodebuild test from the command line for CI/CD, the tests fail because the Run Script did not get executed during the build process.
Is there a way to tell xcodebuild to use the Run Scripts from my Xcode project? Or is there a flag I can use to specify a script for it to run?
Judging by the radio silence, I'm guessing this isn't possible using an xcodebuild flag or changing any Xcode settings.
What I ended up doing as a workaround was splitting build and test commands and then running my script in between.
# build-for-test is used bcus normal build wont build the test bundle, which was important in my use case
xcodebuild build-for-test ...
bash path/to/run-script.sh
xcodebuild test ...
The xcodebuild test command will use the files compiled by the earlier build command, so it won't clean any changes made to the xcode build dir by the run script (which is what I was doing).

Continuous integration with microcontrollers

Just learning about CI and jenkins and wanted to take this concept to the embedded (basically microcontroller) world. The first step is just making sure builds don't break, but then I realized, I don't have a way to execute a build from a shell script on a linux machine (ubuntu server) for a build that usually happens with an IDE on a windows 7 VM. How can I automate opening up a Windows 7 VM and then building an MPLABX project for example.
I'm doing the same thing; a Jenkins server running on Ubuntu, and builds need to happen on Windows with some toolchains that don't always work well for automated builds (IAR in my case).
You can set up a Windows machine/VM with the right tools (incl. Java and git or whatever SCM you use), and install a Jenkins slave agent on it (see https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines).
Connect it to the Jenkins server as node/slave.
Now create a job that uses the "Windows batch command" build step. Your IDE probably has some way to build a project from command line.
Add a post-build step to archive artifacts, i.e. the built files you care about.
-> You can connect your Windows VM as jenkins node and activate Jenkins as service in it.
-> Try to build or run your project from command line. (windows cmd prompt)
-> If your tool has own prompt then invoke your prompt by using normal windows prompt and use.
-> After this you can run your commands in Jenkins using "Windows batch command"

Msbuild works via VS and command-line, but fails via Jenkins

I am trying to build a VS .sln that has multiple C++ .vcproj's in it. The solution file is generated using CMake and I've got this part working in Jenkins (with the CMake builder plugin). To build the solution file, I am using msbuild. I am able to build the solution using both Visual Studio and from the command line with the following command:
C:\Jenkins\workspace\SonioTest>"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" /t:Rebuild bin/SonIO.sln
This builds successfully (on the same machine that Jenkins resides).
However, I am trying to automate this portion of the build in Jenkins and the build ends up failing with a couple of C1083 errors ("Cannot open source file: '..\path\to\file.ext': No such file or directory). I have tried using both the Jenkins msbuild plugin and using the exact same command that works in the terminal as a "Execute Windows batch command" build step, with the same result.
When using the Windows batch command build step, I can see in the log that the command being executed:
C:\Jenkins\workspace\SonioTest>"C:\Windows\Microsoft.NET\Framework\v4.0.30319 msbuild.exe" /t:Rebuild bin/SonIO.sln
... is exactly the same as the one that works from the command line, including the working directory.
I am running Jenkins as a service and I have the service logon as my account (with administrator privileges). Anyone know what directory Jenkins will execute batch commands out of?
Any ideas why I'm seeing this difference of behavior between Jenkins and the command line?
This is as much a workaround as a solution, but I ended up using devenv instead of msbuild and it works fine.
I know that this hints strongly as it being an environmental issue, but since it's not a problem to have VS installed on the build server, I decided to save the time that would be spent in the msbuild rabbit hole.
The environment being used by the account that the Jenkins slave agent is not the same environment as you use when doing the same command line from a prompt. Compare the two environments, note the difference, then add them to the Jenkins job.
To get the environment of the slave while running, have it do a "set" from a Windows Command Prompt
Without knowing much about VS build, it looks mostly like an environment setup.
My first advice would be to make sure, in Jenkins, you change directory to the same directory you ran the good command from and try it then.
Also, might want to try running Jenkins as a standalone app first.
And as a service, maybe allow service to "interact with desktop".
I may be late to the party, but I still ran into this problem on a new Jenkins setup on Server 2016.
My solution was to use the MSBUILD straight from the VS2017 installation C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin. No more errors.

How to run a jenkins pre-build step that depends upon the jenkins slave OS?

In my company, jenkins is configured with one Windows slave and (to come soon) one Mac slave. we want to have a Glassfish domain started as pre-build step, and domain stopped as post-build.
From what I understand, I have to run a "windows batch file pre-build step" on Windows, and a "shell script pre-build step" on Mac.
Can I put both in pre-build steps ? Or should I use an other solution (and if so, which one) ?
You cannot put both in the same job. When the job runs on Mac slave, the "windows batch" will fail. When the job runs on Windows slave, the "shell" will fail.
Why are you trying to add both? I understand that you need the relevant pre-build step, but why are you trying to make the job generic to be executed on either Mac or Windows? Usually running a Mac slave serves a specific purpose (such as doing an Xcode iOS build that cannot be done on a Window), and you restrict that job to run only on Mac slave
If you really need the ability to run either Windows or Mac shell, then you should have a look at XShell plugin
https://wiki.jenkins-ci.org/display/JENKINS/XShell+Plugin
It allows you to execute a "shell" step, on either Windows shell or Mac shell. The plugin will take care of calling the correct shell, and will even do the file separator conversion for you (it will use \ for Windows, and / for Linux/Mac shell), but the commands you put there must be executable in both shells (i.e. it will not translate rm into del for you). The Plugin page gives an example how you can "wrap" the commands into a batch and shell file.

Emulate Run button in Xcode from command line

I'm looking for a way to build and run my app in the simulator from the command line. I need it to behave the same way as when you press Run in xcode.
I can build it with xcodebuild and I tried using simulator with -SimulateApplication option. My app launched but my tests didn't start executing (as they do when run from xcode).
I tried the script I found here and few other AppleScripts I found on the web. They didn't work for me. Commands like build and clean were ignored and others would throw errors. Maybe it's because I use xcode 4. Please help.

Resources