Continuous integration with microcontrollers - windows

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"

Related

Teamcity cli step fails in continuous build while works manually

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.

Batch as a windows service

I am running a Jenkins on windows machine with the process of Jenkins.war.
'java -jar jenkins.war'. If I close the command prompt of the service, Jenkins will go down. I want the Jenkins to be up even if the command prompt closed and even after machine reboot, this jenkins to be started. How can we do this on windows machine?
You can use create-windows-service-from-executable to make your jenkins.exe as a service. Or else while installing itself, install as a service rather than starting from command line

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.

jenkins: windows xp, windows 7 slave cannot execute commands

I have a Arch Linux master that drive 2 arch linux slaves, 1 windows xp slave and 1 windows 7 slave. Linux part is all ok, I managed in some way to start windows slave using automatic execution and slave.jar. I have an external program that need to be executed and it's installed on c:\program files (x86) on windows7 and on c:\programs on windows xp.
I went on path variables and inserted the two path on the two systems, but when I try to run jenkins build it says "command not found"
I tryed to place 2 bat files in c:\ poining to the right place, based on every system, but it says c:\build.bat command not found. I can see the file in the right place...
How do you manage executables placed in different places on different computers?
there's a better way to run the program?
I can change everything about this installation, the only thing I need it to find a way for starting that program.
thank you for your help.
Have you verified that the changes you made to the system path were actually saved? Make sure both of the slaves have been rebooted and then test this via a standard command line window.
If the program you're trying to execute is actually on the path, you could also look at the Envfile Plugin.
After adding new paths to your environment variable PATH you need to restart jenkins slave service in order to allow it to use these new PATHs.
I solved the problem changing the way jenkins start the job on the slave. I used "Execute shell" and some program are executed. I changed "Execute shell" with "Execute windows batch command" and everything works fine.

Resources