How to remove default demand DotNetFramework from TFS agent? - tfs

I am using TFS 2017 and recently added RHEL Linux build agent with docker installed on it, but when I am trying to queue docker based build on this agent I am getting below error
Issues with deploy phase 'Run on agent' - No agents could be found that match the following demands (queue: 'DockerLinuxRHEL'): DotNetFramework
I have also tried removing it from build definition, but it's greyed out.
Is there a way to remove this default demand because this agent is just for docker stuff I don't want to install anything else?

It because you have a task that required .Net framework installed, like PowerShell, MSBuild, etc.
When you will remove the task the demand will be removed.

How to remove default demand DotNetFramework from TFS agent?
I am afraid we could not remove the default demand DotNetFramework.
Just like Shayki said the demand comes from the powershell task itself. So, if we want use the powershell task, we have to install the Net Framework on Linux machine.
However, it's not recommended to build .net framework projects in Linux environment. Usually we use mono with reference assemblies and the dotnet cli to do that.
More details please refer to this blog and the discussion here.
So, remove default demand DotNetFramework or install Net Framework on Linux machine is not a viable option.
To resolve this issue, we could use the PowerShell Core task:
- pwsh: # inline script
workingDirectory: #
displayName: #
failOnStderr: #
errorActionPreference: #
ignoreLASTEXITCODE: #
env: # mapping of environment variables to add
Note: pwsh runs PowerShell Core, which must be installed on the agent or container.
Hope this helps.

Related

Run a gitlab CI pipeline in Docker container

Absolute beginner in DevOps here. I have a Gitlab repo that I would like to build and run its tests in the Gitlab pipeline CI.
So far, I'm only testing locally on my machine with a specific runner. There's a lot information out there and I'm starting to get lost with what to use and how to use it.
How would I go about creating a container with the tools that I need ? (VS compiler, cmake, git, etc...)
My application contains an SDK that only works on windows, so I'm not sure building on another platform would work at all, so how do I select a windows based container?
How would I use that container in the yml file in gitlab so that I can build my solution and run my tests?
Any specific documentation links or suggestions are welcomed and appreciated.
How would I go about creating a container with the tools that I need ? (VS compiler, cmake, git, etc...)
you can install those tools before the pipeline script runs. I usually do this in before_script.
If there's large-ish packages that need to be installed on every pipeline run, I'd recommend that you make yourown image, with all the required build dependencies, push it to GitLab and then just use it as your job image.
My application contains an SDK that only works on windows, so I'm not sure building on another platform would work at all, so how do I select a windows based container?
If you're using gitlab.com - Windows runners are currently in beta, but available for use.
SaaS runners on Windows are in beta and shouldn’t be used for production workloads.
During this beta period, the shared runner quota for CI/CD minutes applies for groups and projects in the same manner as Linux runners. This may change when the beta period ends, as discussed in this related issue.
If you're self-hosting - setup your own runner on Windows.
How would I use that container in the yml file in gitlab so that I can build my solution and run my tests?
This really depends on:
previous parts (you're using GL.com / self hosted)
how your application is built
what infrastructure you have access to
What I'm trying to say is that I feel like I can't give you a good answer without quite some more information

What is the difference between running jenkins with .war file and using installer?

I would like to know what are the difference between using Jenkins on terminal with .war file vs using installer. And which is better?
Always use the installer if you can. My main experience is with Linux but I’m pretty sure this applies to Windows as well:
The installer will automatically pull in any dependencies that Jenkins needs in order to run
You can easily upgrade Jenkins and its dependencies by installing a new version of the package
It will set up Jenkins as a service that will restart automatically if the server reboots
It provides a script to set parameters such as the JVM memory allocation and the port number that Jenkins runs on - if you use the JAR file you’d have to write a script yourself.

What is the right way to add Maven and Ant to a Jenkins Docker container?

I downloaded the jenkins/jenkins:lts image from docker hub which I got up and running on Ubuntu 16.04. The image doesn't seem to include Ant or Maven, and may also want to do builds against different versions of the jdk. I am wondering what is the right way to adress this - can I just run bash on the container and run apt-get or yum as the case may be to install extra stuff needed for my builds, or is there a better way?
Jenkins can automatically install Maven and Ant.
First, install the Ant Plugin by going to Manage jenkins > Manage Plugin > Available and install the Ant Plugin.
Next go to Manage jenkins > Global tool configuration then add Maven and Ant.
Once a build requires Maven or Ant, they will be downloaded and installed.
Installing your tools directly in the running container is probably a bad idea as changes won't persist. Instead, I see the following options:
Let jenkins manage your tools like proposed by yamenk
Clone the jenkinsci docker repository and build your custom jenkins image including build tools you need
Run build jobs in docker containers
I used option 3 with success just recently:
Run build jobs inside docker containers (look into Jenkins pipeline plugin, or just run it from a shell step)
Each build container has a single responsibility and provides all the tools your build environment needs
Support for different tools and versions is unlimited; new technologies can be added in no time
Another (more tricky) alternative is it to use Docker Containers for your tools.
I can recommend the following two articles:
https://jenkins.io/blog/2016/08/08/docker-pipeline-environments/
https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

Release Windows Service from TFS 2015 Build

I have a windows service project that has a Build ready and now needs to be installed at the target machine and run. There is no task in TFS Releases that allows that to happen. What are my options other than writing a custom PowerShell script?
For the current approach, you need to install the build and deployment agents on a set of proxy servers in an agent pool and drive deployments to remote target servers.
The simplest way is using remote powershell task to achieve the installation. Details about the task please take a look at Deploy: PowerShell on Target Machines
In the near future, you could also use Agent-based deployment in Release Management. For this, you can install the agent on each of your target servers directly, and then drive rolling deployment to those servers. More details please refer this blog: Agent-based deployment in Release Management
You can do this easily with Team Build.
You use the "Copy" task on the Release tab to send the files to the machine that you want, and then run a remote PowerShell to do the installation.
You can even deploy the same Windows service to 10 machines using "Machine Groups".

Run deployment script from TFS build workflow on remote system using MSTest agent only

My Question: How can I run a deployment script from the TFS 2010 build template on a remote system that has only a MSTest agent running?
I know this can be done by activating the Deployment section in the test settings configuration file, but this is not flexible enough. At night a build runs. When the build is successful, a deployment script is placed at a drop location. The drop location is date, project and build definition specific. These parameters are available in the TFS build template we use.
I do not have Lab Management available, just a physical server. I would rather not spoil the physical server with an additional build agent to only do the deployment. The MSTest agent is apparently capable of running deployment scripts, but how do I use that functionality from the TFS build workflow. For example, can I use the RunDeploymentScript activity without having Lab Management?
PSExec is a great tool for running scripts on remote computers. I use this in Team Deploy that allows you to install MSIs on remote computers from Team Build. You can also run PowerShell on remote computers but it is a little more complicated to set up. Another option is to use MSDeploy. There is a command option that you can run any command on a remote computer. I usually use an InvokeProcess activity to call a PowerShell script on the build server. From the PowerShell script I have called MSDeploy to run a remote PowerShell script on a target server. It sounds bad but worked good.
You can't run the RunDeploymentScript on the target machine. You can use a modified template to deploy to a physical environemnt. Here is a good post on doing this.. The options I mentioned above do not need any agent on it. You can use the ExecuteRemoteTestRun lab management activity without Lab Management to run the MTM Tests with the Test Agent with a Test Controller that is registered to the project collection (Test Manager).
Let me know if you have any questions on any of these options.

Resources