I have an pipeline where i am calling other pipeline.
I want to see the values passed and the action happening when i debug.
In the below, during debug, i want to see what is the value sent with breakpoints for each flow of parameters and also want to see the PL_Purge Folder in action with debug
!PIPELINE PURGE]1
How to do it,. can you share some links
I think you have the only option to use the set variable activity and assign the value #item().XXXX . When you do that & run the pipeline you will be able to values at the pipeline output tab , nothing like a break point in a IDE , but since you have only 4 inputs which you are tracking this should be doable .
Please do let me know how it goes .
Related
I am facing the issue with for loop execution with logic APP in azure. Apparently complete playbook execute successfully and functionally its working good. However, i am getting this error because it takes "body" parameter from previous step as input and nothing else. The body is long json and therefore should not be the right input for foreach loop. I tried adding account or Ip address as input but that fails as well.
Input
Output
Please help here
As you mentioned there is just one item in your json data array which contains "MachineId", I assume the first item contains "MachineId". Please refer to the solution below, it will help you to use the only "MachineId" in the 24 cycles of your loop.
We can input an expression to use the "MachineId" in first item:
body('Parse_JSON')[0].MachineId
(In the screenshot above, I just use a "Set variable" to replace your two actions in "For each" loop, but I think there is no difference between them)
Please have a try with this solution~
I wanted to run Cucumber Feature file based on the Test case ID that scanerio name contains.
I know we can use #CucumberOptions 'features' tag and specify the line number to execute e.g "src/test/resources/Folder/myfile.feature:7:12"
This will run scenarios at line 7 and 12. But i wanted to run based on the TC ID.
Below is the feature file code
#Run
Feature: Login Functionality
Scenario: First Test Case(TC.No:1)
Given I perform action 1
Scenario: Second Test Case(TC.No:2)
Given I perform action 2
Scenario: Third Test Case(TC.No:3)
Given I perform action 3
Scenario: Fourth Test Case(TC.No:4)
Given I perform action 4
Scenario: Fifth Test Case(TC.No:5)
Given I perform action 5
All the scenario's are in a single feature.
For the feature file code above i wanted some way through which i can execute based on TC Id. E.g I only want to execute TC1,TC2 and TC5( TC id's picked up from scenario names).
There is a property file that contains the TC Id's to be executed. My code should read the file and then execute only those TC id's.
This can help me in reducing the number of automation TC's to be run.
Is it possible?
You can use the name property of #CucumberOptions or use the '-n' option if you are using the cli option. It also supports regular expressions.
To run TC.No:1 and TC.No:4 use something like this
#CucumberOptions(name = { "TC.No:1|TC.No:4" })
or
#CucumberOptions(name = { "TC.No:1","TC.No:4" })
You can get more details at this link.
As you are reading the ids from a file, the second option is the best. Use the cucumber.api.cli.Main class main() method to execute the features. You can create the options dynamically. Refer to this post.
CLI reference docs.
Not familiar with cucumber-jvm.
But, here is the general logic which should work (based on my ruby Cucumber knowledge)
In the hook, you can write the logic to under before method to get the scenario name scenario.name and then extract the TC.No. Compare the TC.No and skip if it's not part of your list.
Here is the link which will give information how to skip the scenario (use this class in the before method)
https://junit.org/junit4/javadoc/4.12/org/junit/AssumptionViolatedException.html
However, the best practice is to use the tags, it would have been easy if you had #TCId-xx tag. Still you can write a simple program that will scan all the feature files and update the scenarios with the tag based on the TC.No in the scenario name.
I want to find the target branch when a pull request is submitted on GitHub, in my Jenkins pipeline. To achieve this I am doing the following:
I am invoking a windows batch file from my Jenkinsfile, which in turn invokes a nodejs script. This script internally invokes GitHub APIs to get the target branch which is to be set on some variable in Jenkinsfile(code snippet given below):
Jenkinsfile
env.TARGET_BRANCH = bat "GetTargetBranchFromGit.bat ${env.BRANCH_NAME}"
BatchFile:
node getTargetBranchForPR.js %1
But unfortunately, the variable env.TARGET_BRANCH is not getting set to the target branch even though the nodejs script gets the right value. I am in fact not able to return the value from the batch file. Could someone please help me here?
#npocmaka mention is the right way: How to do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?
Accodring to Jenkins' documentation.
returnStdout (optional) If checked, standard output from the task is
returned as the step value as a String, rather than being printed to
the build log. (Standard error, if any, will still be printed to the
log.) You will often want to call .trim() on the result to strip off a
trailing newline.
So your code should look like
env.TARGET_BRANCH = bat( script: "GetTargetBranchFromGit.bat ${env.BRANCH_NAME}",
returnStdout: true
).trim()
If you get back more than expected you probably need to parse it.
I have set FLAG as 1 and I am execpting ARG value should be DEV only. But am getting as ARG= DEV + CLIENTID
000023 // FLAG=1
000026 // IF (&FLAG=1) THEN
000027 //SET1 SET ARG=DEV
000028 // ELSE
000029 //SET2 SET ARG=DEV+&CLIENT
000030 // ENDIF
It mean JCL assign the value in RUNTIME (before checking the IF Condition).
Please help me to understand.
Thanks!
Bharathi
What #hogstrom said is correct. The JCL IF statement tests Step Return codes and not Variable values:
//IFBAD IF (ABEND | STEP1.RC > 8) THEN
Following on from what he said you can use a variable in an include statement
Include With variable
// INCLUDE MEMBER=OPT&FLAG
and setup members in the proclib
MEMBER=OPT1
// SET ARG=DEV
MEMBER=OPT2
// SET ARG=DEV+&CLIENT
You have to setup an include for every possible value of &FLAG and it is very long winded for one SET. It is more commonly used when you can set lots of variables like:
// INCLUDE MEMBER=ENV&ENV
where &ENV=PROD \ TEST etc
Your case
Do not use flag, just set the variable:
// SET ARG=DEV
or
// SET ARG=DEV+&CLIENT
There is some good information in the JCL Manual to understand the purpose of the IF/THEN/ELSE purpose.
Here are a few bullets from the manual:
The IF/THEN/ELSE/ENDIF statement construct does not conditionally control the processing of JCL; rather, it conditionally controls the
execution of job steps.
The result of processing an IF/THEN/ELSE/ENDIF statement construct, once determined, remains unchanged regardless of the outcome from
running any remaining steps in a job. The system does not reexamine
the original condition at any later job step termination, either
normal or abnormal. See Example 9.
The system allocates all DD statements defined to a step if the execution time evaluation of the relational-expression determines
that a step is to be executed. All data sets defined on DD statements
in the job must be available at the time the job is selected for
execution.
You can nest IF/THEN/ELSE/ENDIF statement constructs up to a maximum of 15 levels. You can specify symbolic parameters on
IF/THEN/ELSE/ENDIF statements provided that they resolve to one of the
supported relational-expression keywords. Any other symbolic
parameters, even if accepted by the system, are not intended or
supported.
What your doing seems logical, but, its not the intended purpose of JCL SET and conditional logic.
In your case, the last SET executed is what is used and why your seeing the DEV + CLIENTID
I'm using Uno choice plugin to select parameter values based on previous selections.
(This plugin helped me to reduce parameter count. I can reuse same parameter for multiple platform based on the platform selection)
I used the groovy script to select parameter values.
But it takes too much time to load parameters.
Is there any way to speed up this process?
I had faced similar issues and I was also using groovy scripts to cal shell scripts.I did the following things to reduce time:-
When you click on build with Parameters all task(scripts run at once together) are performed at once.
Use else conditions properly.
Also use Fallback script.
For eg:-
you have parameters such as
1) country
2) state
3) city
each parameter depends on the previous values.
1) Try to only display contents on Jenkins front-end.(cat command).
2) Call a script if only it matches valid values in the previous parameter.
3) minimum on the fly scripts.
4) optimize delays/sleep according to your load time.
5) Remove any extensions whether in chrome/Firefox.
5) Try using the same page in incognito mode.
6) If options are invalid through invalid option without going into any computation.
7) Uninstall plugin which are not required.
Will add more suggestions as I find.
I would request you also to please update if you find any method to optimize time.