PreBuild Definition || Execution of script - tfs

How to run scripts in build definition (preBuild) in TFS2013? I don't see any option for PreBuild Definition for script run.

If you just want to run a PowerShell script or a batch (.bat) file before the system compiles or tests your code. You can use Default Template( TfvcTemplate.12.xaml ) which include the Pre-Build Script options. More info from MSDN.
If you can't change the build template, you can custom your build template to meet the needs. Detail guides from official https://msdn.microsoft.com/en-us/library/dd647551(v=vs.120).aspx You can also learn about the process in the ALM Rangers Build Guidance

Related

How to find out the the definition of gradle executed task in Jenkins

I am new to SCM tool like Jenkins so I may not actually ask the right question.
I find out there is a specific Gradle executed task failed when check the logs of Jenkins.
However, I cannot find out where the Gradle executed task is defined and what is the content of it.
I look up the [CONFIGURE] of Jenkins and then in the [BUILD] section, there is a section called [Invoked Gradle script] and I could see the name (lets call it X here) of executed Gradle task I am looking for.
But I cannot find where X is really defined and what command it actually run, Does anyone has any suggestion? Thanks.
You can try using gradle in verbose mode
gradle -S build
-S, --full-stacktrace
Print out the full (very verbose) stacktrace for any exceptions. See also logging options.
or try using debug mode
-d, --debug
Log in debug mode (includes normal stacktrace).
https://docs.gradle.org/current/userguide/command_line_interface.html
Gradle provides a Domain Specific Language (DSL), for describing builds. This uses the Groovy language to make it easier to describe a build. Each build script of Gradle is encoded using UTF-8, saved offline and named as build.gradle.
By default, Gradle command will invoke Gradle script from build.gradle file.
You can run a Gradle build using the Gradle command. This command looks for a file called build.gradle.
More details here.

How to use the Jenkins MSBuild plug-in in a Jenkinsfile?

I have Jenkins v2.60.3 with the MSBuild Plugin v1.27 installed on Windows.
I have configured the path to my msbuild.exe in Jenkins' Global Tool Configuration. I have also setup a Multi Branch Pipeline in Jenkins that picks up a Jenkinsfile from git repo successfully.
My question is: How do I invoke the MSBuild Plugin as a step in my Jenkinsfile?
Please note I know I can invoke msbuild.exe directly as a Windows batch step but I prefer to go through the MSBuild Plugin if possible.
`
It looks like MSBuild is not supported by pipeline yet
https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md
You can try this in the meantime.
https://github.com/jenkinsci/pipeline-examples/blob/master/jenkinsfile-examples/msbuild/Jenkinsfile
Our teams need to migrate a ton of freestyle MSBuild jobs that were created in the UI. mjd's answer helped but still left me scratching my head. The examples just didn't work... until I figured out the disconnect.
Here's the secret sauce:
You have to call the "named msbuild configuration" directly using the
"bat" and "tool" commands.
go into the Config of one of your freestyle jobs that uses the MSBuild plugin
scroll down to the msbuild section and click the "MSBuild Version" drop down, take note of the exact names that are listed. This is your 'named msbuild configuration'. Choose one name that you will use in the next step.
open your jenkinsfile, locate the stage and step where you want to call msbuild, then add this line and replace 'MSBuild 15.0' with the name that you chose in step 2:
bat ""${tool 'MSBuild 15.0'}\\msbuild" SolutionName.sln /p:Configuration=Release /p:Platform="Any CPU" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
like so...
(For Declarative Pipelines, you'll need to put this inside of a "script" block. If you don't know what a 'Declarative Pipeline' is, it is one of two styles of writing pipeline scripts in Jenkins using the "groovy" language. For more info here is a comparison of the scripted vs declarative styles.)
run the pipeline and examine the output - the code you added in step three won't build anything, you just want to use it to see if msbuild will actually get called before investing anymore time into my script.
(I usually use the Replay button which allows me to edit the script online in Jenkins rather than editing, committing, and pushing to remote repo... it just saves a bit of time debugging.)
examine the output of the pipeline job you ran in step 4. You should see something like below indicating that the correct version of MSBuild was called. If not, you either have a typo or your administrator needs to intervene.
workspace\Pipeline_Test>"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\MSBuild\15.0\Bin\msbuild" SolutionName.sln
/p:Configuration=Release /p:Platform="Any CPU"
/p:ProductVersion=1.0.0.308 Microsoft (R) Build Engine version
15.9.21+g9802d43bc3 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved.
Congratulations you can now configure your build! Replace SolutionName.sln with your build file and pass the correct parameters to it.
I am surprised that all solutions doesn't work for me.
Platform : Window 10 Jenkins at latest version in 2020-11-05.
I am not sure if there's any reason that window & other OS will cause the pipeline script engine behaved differently.
Below are the possible encountered issues and solution finally combined with the above solution.
in my compiler, a single '' will cause error, '' must be escaped by replaced by '\'. which is similar to other char such as '"'
${tool 'MSBuild'} OR ${tool 'MSBuild 15.0'}\msbuild\ does not work, the error is the path cannot specified or cannot find the bat program. It must be an absolute path of the actual msbuild.exe
So this is the working solution for adding MSbuild in the pipeline script in window platform's jenkin
bat '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild" YourSolution.sln /p:Configuration=Release /p:Platform="Any CPU" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}'

Triggering Robot Scripts from Jenkins

I am new to Robot Framework and I need to trigger my scripts from jenkins. Can someone give me a step by step guide for the same.
The ways Jenkins may access the test data and the ways to trigger Robot Framework scripts from Jenkins are numerous, so I am not sure how useful a step by step guide would be.
Start out simple - use a Execute shell or Execute Windows batch command build step. The script should read something like
python -m robot.run path/to/tests. The current directory is the root of the workspace.
Typically the tests would be put in the workspace by the Source Code Management configuration of the job.
As you add more and more jobs, you may want to have a common script to invoke Robot Framework, so that common configurations can be extracted out of individual jobs. If you want to always exclude certain tags (e.g. WIP), use a listener, or control where the output goes, using a common script is useful.
I highly recommend adding a post-Build step in the project for the Robot Framework plugin for Jenkins.

Build LaTeX PDF on Jenkins/Hudson

The team I work for manages a large collection of technical documentation which is written in LaTeX. Currently all the documentation we have is manually built by the editors and then checked into a version control system.
Is there a possibility to build the LaTeX files on jenkins/hudson?
If you can build your LaTeX files from the command line, Jenkins can build it for you.
Just create a job with a "Execute shell" build step.
You've tagged this question with [ant], so if you're building your documentation using an Ant script, you can alternatively add an "Invoke Ant" build step which calls the appropriate target.
Depending on which build system you're using you can also use plugins e.g. for Maven or Gradle. You can have a look at https://github.com/reallyinsane/mathan-latex-maven-plugin where you can find a maven and a gradle plugin. You can use them with none or less configuration.

What is the best approach to implement an RTC build for WebSphere

I would like to utilize the RTC (v2.x) build for Java EE projects created in RAD (v8) and deploy them on WebSphere (v7).
Independently of RTC build i am able to create all sorts of ant scripts and jython scripts to perform automated tasks. The problem is to integrate this into a single RTC build.
The path I'm on now is:
- RTC build definition calls external build command which is a ms-dos .bat file that call's the Rational Build Utility headless ant with an ant build script.
- The ant build script uses 1)projectImport 2)workspaceBuild and 3)exec to call wsadmin with a jython deploy script.
Right now the build fails because the workspaceBuild task fails because we've defined a target runtime that does not exist in the headlles ant workspace. If someone knows how to add/define a new target runtime into a headless ant workspace that would be very helpfull.
I can't help feeling that i'm on the wrong track and feel quit stuck between the different environments and I'm wondering how other people implement their RTC build for a WebSphere target.
Thanks.
There's a DeveloperWorks article that explains how to use the RAD Ant tasks in a continuous build scenario. For the target runtime, you would define that in Eclipse, export your preferences, then import them during the build using the workspacePreferenceFile Ant task with useEclipsePrefs="true". The article uses Hudson, but the same approach should work for RTC Build.

Resources