How to pass a Variable value to a variable in the code in bitbucketPipe lines - bitbucket

Hi There was hoping someone could assist in anyway , i am new to bitbucketPipe lines and use it to run my automation scripts in parralell in my code i have a value that needs to be checked against a new version of software , however in order for this value to be updated i need to update the code and then push which runs the pipeline again , my goal is try to configure this value in bitbucket let the code use this value to assert against and in the same pipeline without changing locally first then pushing, not sure if this is possible eg :
Value1 == value2
Value1 will be obtained by the selenium script
Value2 I would like to set in bitbucket

Related

How to set jenkins string parameter in Windows batch command

I have declared a string parameter in Jenkins i.e "Year".
The value is to be set in windows batch command, because i thought this was simple without a plugin.
Below screen depicts on how i am setting the parameter Year.
When I do echo can see in the console correct data is displayed however when I try to use the same parameter after this execution in next set as ${params.Year}, it seen as empty.
What I am doing wrong here? not able to figure it out.

How to select the parameter coming from script output and pass it to next script or job in Bamboo?

I am trying to do below things in bamboo.I have script which basically shows the branches of hg repository.I know there is a plugin in Jenkins where you can run the script and get the output and use that output as a parameter to the job/script but I am not sure how to achieve this in Bamboo.Is there any plugin or some way to achieve this?
script abc.py which gives the below output
a
b
c
d
e
f
g
I want this script will run and it will give me the above output and then I can select anyone of them and pass it to my script.The value of the createBranch should come from the script so I can select any one of them
With Bamboo, it is impossible to create/change a variable value from within tasks due to concurrency issues it might create. There is a feature request open for this.
As a workaround, how about writing the script result out to a text file, then read it in from the file using Inject Variables plugin task. You can use this as a variable within the same stage to create a branch in your case.
Hope that helps.

Jenkins Extended Choice Parameter - using the values

I'm new to Jenkins so this is probably an easy one. I have the Extended Choice Parameter plugin installed. I'm using the Multi Select parameter type to pick from a list of servers (SERVER1,SERVER2,SERVER3) I've set Source for Value, Default Value, and Value Description.
I save it, and it looks great. I can pick any or all servers for the build. Now for the big question.. how do I use these values in the build? Basically I have a step in the build that can take in a comma separated list that is called by a shell command:
d:\python\deploy.py?serverlist=$blah
What do I put in for $blah to use that list of servers?
Just to be clear, if I'm on command line I would do the following:
d:\python\deploy.py?serverlist=SERVER1,SERVER2,SERVER3
I'm sure it's something simple but I just cannot find it in the docs or an example.
We could get the servers list like this
d:\python\deploy.py?serverlist=$SERVERLIST
or this on Windows
d:\python\deploy.py?serverlist=%SERVERLIST%
To see the list of environment variables which we could you, try this URL (change localhost by your Jenkins URL, TEST by the job name, 10 by the build number)
https://localhost:8080/job/TEST/10/injectedEnvVars/
UPDATE to #sniperd's edition:
This URL will shows us the parameters list in the Job:
http://localhost:8080/job/TEST/59/parameters/

Cannot receive parameter from Script content to Predefined Parameter in Jenkins

I would like to pass hostname parameter which is declared at Script Content to Predefined Parameter in Trigger/calls on build other project where my child project will receive parameter from the parent project.My code looks like this in Script Content:
`machine_name="$(hostname)"`
So in order to pass my parameter to the child project I declared:
host_name=${machinename}
in Script Content .But when I check in my child project it display as ${machinename} which is not I want .Can someone tell me what am I missing or what step that I done wrong or is there any way to perform this ?
Try using ENv Inject plugin, all you need to do is below:
Your script should contain below step:
machine_name="$(hostname)" > inject.txt
Now use Inject environment variables build step and in
property file path give inject.txt
what's the use?
By this step, now you machine_name variable holds the hostname value throughout the job.
Next, in your Parameter in Trigger/calls on build other project
host_name=${machine_name}
And use the same variable in child job.
I think there is no need for multiple assignments above, but still you can try this.
'_' was missing. host_name=$machine_name.
you cannot set or pass the parameter value from the script o/p. either make it as env variable using groovy or set in to property file & read.

Updating the Jenkins Variable with a value calculated in a batch file

I am new to Jenkins. My aim is to define a build job in which I have created an environment variable suppose "x" by checking "This build is parameterized" option. I am executing a batch file which is performing a set of instructions and I want the x to be updated by a value calculated in batch file. Any suggestions how can I update the Jenkins variable value calculated using a batch file. I have tried using enviject plugin but not getting how to update the variable.
Thanks in advance
enviject plugin should be helpful here.
But - you need to update your batchfile to create a property file.
As the first step in the build action, I am passing some properties to my test.
Then, I use the property name like a parameter passed to Jenkins to execute a windows batch command. This bat file creates a result file in .properties format.
As the third step, i read the (result) property file. The result property file can have the same properties with updated values.
Now - your original proeprties would have been updated with new values & can be used in your subsequent build steps.

Resources