I have one project where we have different Jenkins files for different workflows. I need to implement new requirements for this project Jenkins files.
My requirements are like this,
1- I have a set of common parameters that will be used for two workflows. I have one choice based parameter which has four choices. If the parameter has choices "A, B, C" then use the actual workflow already implemented in one Jenkin file
(A) and If the parameter has a choice "D" then use the new workflow which is implemented in other Jenkin files (B).
The question is how can I implement this requirement. Should I need to add all parameters in both Jenkin files or should I need to create another Jenkin file as master and define all parameters in that file and put some conditions over there to call the other Jenkins files on choice-based.
If anyone works on such a requirement or has a good experience to explain the solution, then please write me back with the proper solution. So that I can implement it.
Thanks.
Related
I am creating CI/CD pipelines in VSTS using GIT repository.
I need to use the same steps from UI while creating build definition and release configuration for projects so i want to get off this repeating manual steps and create some automation around it so I don't have to do the same steps every time.
Can anyone tell me how it is possible using scripts or any other things?
To create build definitions you have two options:
Use the new YAML builds, which allows you to specify the whole build in a YAML file instead of UI elements.
Use the Build Definition REST API create the definition locally in json form and submit it to VSTS in a single transaction. There is a nice PowerShell library called "VSTeam" which wraps the REST API functions in powershell cmd-lets.
Another thing to look at would be the use of Task Groups, these allow you to abstract away a sequence of tasks and turn those into a single reusable task.
I'm using msdeploy on the command-line to deploy a windows service using the sync verb against dirPath source and destination providers. So far so good.
My project's build assets have per-environment config files, and during deploy to a particular environment I want to rename the targeted environment's config file to the default config file name using a replace rule, but no matter how I engineer my replace rule nothing seems to get me the results I want. I've tried with a number of different configurations of the rule with no luck but the one that seems the most logical is this one:
-replace:objectName=filePath,scopeAttributeName=path,scopeAttributeValue=Service\.Dev\.exe\.config,match=Service\.Dev\.exe\.config,replace=Service.exe.config
If I deploy without the replace rule both Service.Dev.exe.config and Service.exe.config are deployed with the expected respective content. Once I add the replace rule above I get just Service.exe.config and it's got the content of that file from the source, not the content of Service.Dev.exe.config as I am hoping for. If I swap the specifications of the match and replace components (and change regexp <-> plain text accordingly) to arrive at:
-replace:objectName=filePath,scopeAttributeName=path,scopeAttributeValue=Service\.Dev\.exe\.config,match=Service\.exe\.config,replace=Service.Dev.exe.config
I just get Service.Dev.exe.config with the content of Service.exe.config and no Service.exe.config in the destination.
I'm sure I'm missing something obvious, but what is it?
This doesn't directly answer your question but I think its a better solution to your root problem.
The real issue here is config management for different environments. Many developers create different configs for each environment like you do. This approach requires a lot of duplication across your different config files which can easily get out of sync.
The best approach I've found for managing configuration across different environments is WebDeploy Parameterization. It is similar to config transforms in that you have a single base config file that is tweaked, so there is far less duplication. Parameterization however is preferred because it applies the changes at deploy time instead of build time. We use this for 50+ applications with great success.
Here is a blog post with more details - http://www.dotnetcatch.com/2014/09/08/parameterizationpreview-visual-studio-extension/
The match and replace should swap
match=Service.Dev.exe.config,replace=Service\.exe\.config
How can I create different types of Jenkins projects like Maven, Multi configuration etc. and configures them using groovy script that can be run on Jenkins script console? or is there any Jenkins-cli command available in order to achieve this.
In case you know any other approach apart from this please let me know. Thanks in advance.
First - You need the appropriate plugins for the different job types (like the Maven plugin).
If you'll read a bit about the CLI (JenkinsMaster:port/cli/) you can see that you have many actions you can do. One of them is to create a job:
java -jar jenkins-cli.jar -s http://JenkinsMaster:Port/ create-job NAME
You will need to define a job configuration file (a simple xml file) to add using the CLI.
I would suggest creating a Maven job for example, go to your $JENKINS_HOME/jobs folder and see how the xml file is written to better understand what it is you need to do.
And I would also suggest to try and read about Jenkins and how jobs are configured and work. I will add links to great tutorials if needed - comment if you intend to learn and interested.
I have an octopus deployment that needs to go to a load balanced environment But there are small changes in the config between the two servers.
So, in summary:
It deploys to the same environment (PreProd)
It gets deployed to two different servers linked to that environment
There are small changes between the two web.config files between the two servers.
I already have a web.preprod.config that gets transformed into web.config. Does it mean I need to create more config files, ie. web.server1.preprod.config and web.server2.preprod.config or is there another cleaner way of doing it? It is a whole section that is different so not just an appSetting.
A solution that has worked well in similar scenarios for me in the past (with OctopusDeploy specifically), is to use the web.{environment}.config transforms to get the correct config structure in place, but to use variable substitution and define placeholders in the transform file to keep the run-time environment-specific definitions in Octopus. Quite how you break down the substitution syntax is really dependent on your config, but you can use the machine-scoping features of Octopus variables to control the actual values injected.
This scenario is a good example of where web.config transforms start to blur the edges of configuration management; environment-specific config is really the domain of Octopus (or, more specifically, a centralised configuration store), but the solution proposed here is taking it out of Octopus and back into the source repository, which is one of the problems Octopus is actually designed to solve.
For example; what if you introduced a 3rd node in your pre-prod load balancer? This demands a code change, build, version bump and package, which can be completely avoided given the above.
The general approach to problems like this is, indeed, to create a web.server*.preprod.config, or local.config. I'd suggest looking at what exactly is different in the config, and why. Try to find things that you can merge. For instance:
If one difference is the difference in drive letter, and your config contains these entries:
C:/a/b/c.txt
C:/a/b/d.txt
try splitting those entries into
drive=C
drive:/a/b/c.txt
In that case you only have to change drive=C to drive=D to make two entries work.
I have two questions ;-)
Is the "web.xml" in a WAR-File intended to contain project/customer-specific informations
Example: For customerX we want Filters for Bandwith and Compression for customerY we dont want those Filters
How does the Maven-Build-Process allow us to make different Builds for such project/customer-specific WAR-Files.
Should it be done with maven profiles
Should it be done with separate build-processes that integrate the release-project into individual WAR-Builds
To first one i would recommend to say No. You should solve that by using property files to handle such things.
you can handle that with profiles, but with the draw-back that you need to rebuild for every customer you have. Lets say dev, test, prod. This can be solved by properties but that means to build three times..I have described a better solution here which handles the different locations with a single build. That will solve the problem for release as well.
It is also a solution to use a separate maven project (lets call it configuration module) which depends on the WAR file). But this would mean to three different projects like dev, test and production which i find not very handy.