How to configure my Jenkins to auto build and test my Qt project? - c++

I'm a newer to Qt project,strange to its project structure.
I have used jenkins+git+github+MSBuild+xUnit to build CI for VS project in windows.
Now my job is to configure jenkins so that it can auto build and test my qt project(in Ubuntu).
However,it seems there is few information about "jenkins build Qt project".
I don't know which plugins should I use on jenkins and how to configure them.
Can you show me how to do that?(I use Ubuntu 16.04)
I have read this blog,and try to run that way:
https://www.peter.hartmann.tk/single-post/2015/06/17/Minimal-Continuous-Integration-for-Git-projects-with-Jenkins-and-a-Qt-example
In this blog,it use "qmake && make && make check" to do all the thing(build and test) without installing any plugin.what does this command do?Does it work for all Qt project?
What's more,in Ubuntu,can I pack my Qt project using jenkins?If yes,how to do that?(Windows can pack qt project as .exe file, Ubuntu pack as what kind of file?)

I'll just link to already existing materials, which there's plenty of.
In general there's three main steps in what you want to do:
Trigger Jenkins build after git push: How can I make Jenkins CI with git trigger on pushes to master?. That gives you Jenkins job execution (that at this point does nothing) after each git push automatically.
Pulling changes from SCM - that is a ready step within regular Jenkins project that you just click through.
Building your project - in case of QT project which can be built from command line (Compile a Qt project from command Line) you can add this as a simple shell command build step in Jenkins.
Optionally you can then run tests on the result, store your artifacts after a successful build and/or trigger email notifications on failed builds.
As for storing artifacts - there's a ready plugin for that (https://wiki.jenkins.io/display/JENKINS/Compress+Artifacts+Plugin).

Related

How to build a Windows Qt/MSBuild C++ application inside a Jenkins docker container

First of all, I'm completely new in CI.
I am trying to set up a Jenkins to build several C++ projects I am hosting on my own Gitea instance.
The applications I want to add to my Jenkins build pipeline are mostly Qt or MSBuild projects.
I have installed the MSBuild plugin for Jenkins, however I couldn't find a Qt plugin.
Since the Jenkins docker container runs inside a Linux environment and runs on Linux itself too, I couldn't find out how to make Jenkins build MSBuild (.sln) or qt (.pro) projects.
How do I have to configure Jenkins to make it build MSBuild or Qt repositories?
Do I have to create makefile or CMakeLists files?
My goal is to have automated release builds inside my repositories built using my Jenkins docker container running on my Linux machine.
I really couldn't find a useful tutorial or explanation on this.
Thanks a lot in advance.

TFS 2017 - Build and Release

I am very new in TFS, need to implement CICD using TFS 2017 and its build and release feature,
when I tried to run build after creating build definition, I got error like no agent found, I googled and found how to configure agent, but I have logical confusion in my mind as below:
How Agent works with TFS 2017?
Where process of CI will be run on Agent or on TFS server?
Where I need to have msbuild ? where my built code will be placed?
What other dependencies would be there on Agent machine?
all question might be silly but as I have worked with Jenkins and Git, i dont have knowledge of Microsoft technologies, and I can't find well documents for the same.
How Agent works with TFS 2017?
In short to build with TFS, you need to Deploy an agent, in the agent machine you need to install the proper build components/SDKs accordingly based on your project.
Create a build definition. Once a build is triggered , the sources will be downloaded from the TFS repository to the agent machine and then build in the agent machine.
Related documents : Agent pools and queues; Build and Release Agents; Build definition options
Where process of CI will be run on Agent or on TFS server?
You can eanble the CI (turn on the Continuous integration trigger) in build definition. See Configure continuous integration for details. Thus the build will automatically be triggered once changes are checked in.
Related documents: A quick introduction to CI/CD ; Build and release
Where I need to have msbuild ? where my built code will be placed?
For vNext build, it's task based build system. You can define your build definition based on the tasks. See Build and release tasks .
e.g.: You can use MSBuild or Visual Studio Build task, you can specify the MSBuild Arguments as needed.
You can use the utility task: Copy and Publish Build Artifacts and Publish Build Artifacts to specify where the built code will be placed. (Artifact Type : Server/File share path)
What other dependencies would be there on Agent machine?
Refer to the answer for the first question.

Can't run 'ng' from VSTS agent

I'm trying to run unit tests against our AngularCLI project using our hosted VSTS build agents however it keeps running into trouble when it tries to run 'ng test'.
To resolve this I have tried to make the agent use the ng tool directly by providing the path to the tool. This hasn't worked as it looks like it's trying to run 'ng test' where the tool is rather than in the specified current working directory:
I've also tried to add it as an environment variable in Windows (we're using Windows Server 2012 to host the VSTS agent) and setting the tool in the VSTS agent as just ng however it doesn't appear to be finding the ng tool:
How can I get the VSTS agent to make use of the ng tool to run tests? We have got #angular/cli installed on the server hosting the agent.
The thing is that you won't get angular cli installed on VSTS globally as its build server is not supporting that. But the good thing you not even need cli globally installed on your agent.
All you need is npm run ng build -- prod - this way it will always run the local version. Also this way you won't need to take care of updating your global package at all.
Use npm run ng test to run tests, npm run ng e2e to run protractor. If you need to pass any more params to any of these just use --
As mentioned by #Kuncevic, to use the Angular CLI without installing it globally, you will need to use the npm run command.
To run an Angular build using Azure Devops:
Add an npm task to install dependencies (choose install for the command)
Add another npm task, but choose custom for the command. Then add your command and arguments:
run ng -- build --output-path=dist --configuration=prod
Note how npm is not a part of the command and arguments since this will be provided by the task. Also note how -- separates the command to be run and the arguments to be passed to the command.

How to set up TeamCity for Build -> Test -> Deploy flow

I have configured TeamCity with Git to get my ASP.NET MVC project.
My solution contains the web app and the corresponding unit tests:
MY_SOLUTION.sln:
- WebAppProject
- SomeCoreLibrary
- SomeCoreLibraryTests
- OtherProjects...
The steps that I have configured in TeamCity are the following:
Get external packages using NuGet
Build the solution and deploy it
Run Unit Tests
Run Automated Tests (using Selenium)
I want to run the unit tests after building but before deployment and stop deployment if the unit tests failed. Currently the deployment is done after the build using the following Command Line Parameters:
/p:VisualStudioVersion=11.0
/p:DeployOnBuild=true I want this to be done only after SomeCoreLibraryTests.dll unit tests have passed
/p:PublishProfile=MyWebDeploy
/P:AllowUntrustedCertificate=True
/P:UserName=username_here
/P:Password=password_here
Thanks,
Ionut
What I've done in similar cases is to use RoboCopy to just mirror the new website into the deployment path. Doesn't that work for you?
P.S.: if you do get this working, I'd suggest doing a performance improvement change in TeamCity (which would allow you to run the unit tests in parallel to the automated tests):
I assume you are employing a single build configuration for all those steps. If that is the case, what I would recommend instead is using Dependent Build configurations to separate the different concerns. You can see an example here in an open source project of mine:
http://teamcity.codebetter.com/viewLog.html?buildId=112432&buildTypeId=bt1075&tab=dependencies
Log in as Guest and expand the Testeroids :: Publish to NuGet tree node to visualize the build flow.
To achieve this, basically you pass around the result of your build step in the artifacts (e.g. you pass the resulting binaries from Compile into Unit Test). You gain several things by using dependent builds: several independent build steps can run in parallel on different agents, plus if one of your build steps fails because of external factors (e.g. let's say Publish failed because the network went down), you can trigger again the build and it will only rebuild the failed steps.
I am not familiar with the tools that you use. However, I would, in general, use a few build configurations for a project:
build configuration, triggered on change, containing these steps: get the latest source code and packages, build/compile and unit test. Then create an artifact for deployment task.
build configuration to deploy to a development server, triggered by successful completion of and using artifact (via dependency) from (1).
build configuration for long running (eg integration/functional) testing that is scheduled to run less frequently.
An advantage of (2) is that you can, if necessary, re-deploy a build/artifact without having to rebuild the artifact first. Also, if you have multiple agents, (2) and (3) can run independently of each other.
Furthermore, you can also tag build in (2) that have passed development checks and then use its artifact in another build configuration to deploy it to test server, etc.

Jenkins with a Cocos2d-X project

I have just recently moved into developing Cocos2d-X application for Android devices, from native Android application development. I am looking to configure my Cocos2d-X C++/JAVA project in a JENKINS environment.
Has anyone any experience of using JENKINS with cocos2d-X projects ? Any tips on where i can get started ?
You can use the cutom scrip option, for example if you use the cocos2d-x model for build you can build your project with the custom command "make", in adition you can use statically code check, bla, bla, ...
I use too my machine as slave for no put the build environment in the server.
Yes. It depends upon the build tool you are using. I am using Ant with Eclipse. Try to read about building an Android Project from Command Line Using ant or gradle. and there you go,Include "Build Step"-> "Execute shell" in jenkins.
You have to manually check for all dependencies.