MegaPowerRockstar Posted November 13, 2017 Report Posted November 13, 2017 Hi, I have worked on different tools of auto deploying, but new to Jenkins. My question is i need to update the appSettings value based on environment. Is there a environment variable that i can create in Jenkins UI and make my build definition use this variable and update the web.config file. I did such kind of process in Octopus tool.. but in jenkins how ? I checked online but i didnt understand, they are suggesting to use "Environment Injector". But i want to make it simple in UI, so tomorrow something is changed i can do in UI directly. Any advice's ? Quote
infoseeker786 Posted November 13, 2017 Report Posted November 13, 2017 I would do this way.Create qa.web.config,dev.web.config,prod.web.config for qa,dev,prod environments in your source code.In jenkins commandline configuration pass -Denv=qa or -Denv=prod or -Denv=stage etc.These are environment variables .Within code read System.getProperty("env") match it to qa or stage or prod and write code to load qa.web.config or dev.web.config files based on corresponding environment variable Quote
MegaPowerRockstar Posted November 13, 2017 Author Report Posted November 13, 2017 26 minutes ago, infoseeker786 said: I would do this way.Create qa.web.config,dev.web.config,prod.web.config for qa,dev,prod environments in your source code.In jenkins commandline configuration pass -Denv=qa or -Denv=prod or -Denv=stage etc.These are environment variables .Within code read System.getProperty("env") match it to qa or stage or prod and write code to load qa.web.config or dev.web.config files based on corresponding environment variable I am already doing this... but my concern is i want to hide the prod or qa credentials from source control or project. if we have variables from build process where in it can read credentials and the override the config file .. Quote
Spartan Posted November 13, 2017 Report Posted November 13, 2017 config file provide plugin vadochu. @MegaPowerRockstar Quote
Spartan Posted November 13, 2017 Report Posted November 13, 2017 EnvInject will also do. https://stackoverflow.com/questions/44697663/use-jenkins-to-inject-masked-password-for-use-in-code-within-the-build Have a look into the EnvInject plugin, there you can define password parameters that are masked in console output and job configuration, they can be used like normal parameters. The screenshot shows the configuration in the job to use a local password. The shell script build step I used is echo "myPassword = $myPassword" The resulting console output is: + echo 'myPassword = [*******]' myPassword = [*******] Quote
MegaPowerRockstar Posted November 14, 2017 Author Report Posted November 14, 2017 16 hours ago, Spartan said: EnvInject will also do. https://stackoverflow.com/questions/44697663/use-jenkins-to-inject-masked-password-for-use-in-code-within-the-build Have a look into the EnvInject plugin, there you can define password parameters that are masked in console output and job configuration, they can be used like normal parameters. The screenshot shows the configuration in the job to use a local password. The shell script build step I used is echo "myPassword = $myPassword" The resulting console output is: + echo 'myPassword = [*******]' myPassword = [*******] I need to replace the value in web.config... but this one seems to be used at build level... can we use this to replace appSettings values in web.config file ?? Quote
Katti_Ramdas Posted November 14, 2017 Report Posted November 14, 2017 18 minutes ago, MegaPowerRockstar said: I need to replace the value in web.config... but this one seems to be used at build level... can we use this to replace appSettings values in web.config file ?? simple ga web.config debug mode and release modes untay ga.. use release mode for PRod and debug for lower environments.. Quote
MegaPowerRockstar Posted November 14, 2017 Author Report Posted November 14, 2017 2 hours ago, Katti_Ramdas said: simple ga web.config debug mode and release modes untay ga.. use release mode for PRod and debug for lower environments.. i need to hide the values, so no one else can read or use them... so its kind of restricted username and passwords... Quote
Spartan Posted November 14, 2017 Report Posted November 14, 2017 37 minutes ago, MegaPowerRockstar said: i need to hide the values, so no one else can read or use them... so its kind of restricted username and passwords... nenu usual ga a files ni encrypt chesesta even in debug or prod mode. so build machine will it self decrypt it while building. or in ur case may be u can try this plugin ConfigFile Provider. jenkins will store the creds for u Quote
MegaPowerRockstar Posted November 14, 2017 Author Report Posted November 14, 2017 1 hour ago, Spartan said: nenu usual ga a files ni encrypt chesesta even in debug or prod mode. so build machine will it self decrypt it while building. or in ur case may be u can try this plugin ConfigFile Provider. jenkins will store the creds for u i am not able to implement this.. having hard time finding real examples to try that plug in.. all examples are used to show it in console during build but not updating web.config file Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.