Jump to content

Jenkins build experts help needed


MegaPowerRockstar

Recommended Posts

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 ?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 ..

Link to comment
Share on other sites

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. job configuration

The shell script build step I used is

echo "myPassword = $myPassword"

The resulting console output is:

+ echo 'myPassword = [*******]'
myPassword = [*******]
Link to comment
Share on other sites

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. job configuration

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 ??

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...