12 Replies Latest reply on Jun 10, 2014 8:13 PM by Raja Mohan

    Add parameters to NSHScripJob

    Rajeev Gupta

      While I create a NSH Script job, I need to pass parameters to the NSH Script to run. I do as follow:

       

      JOB_FOLDER=${JOB_FOLDER}

      JOB_NAME=${JOB_NAME}

       

      echo "VALUE1="${SHORT_DEPLOY_JOB_NAME}""

      echo "VALUE2="${groupId}""

      echo "VALUE2="${DEPLOY_JOB_RUN_ID}""

       

      blcli_execute NSHScriptJob clearNSHScriptParameterValuesByGroupAndName ${JOB_FOLDER} "${JOB_NAME}" >> nul && blcli_storeenv JOB_KEY

          [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

          [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

       

      blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOB_FOLDER}" "${JOB_NAME}" "0" "${SHORT_DEPLOY_JOB_NAME}" >> nul && blcli_storeenv JOB_KEY

          [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

          [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

       

      blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOB_FOLDER}" "${JOB_NAME}" "1" "${groupId}" >> nul && blcli_storeenv JOB_KEY

          [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

          [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

       

      blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOB_FOLDER}" "${JOB_NAME}" "2" "${DEPLOY_JOB_RUN_ID}" >> nul && blcli_storeenv JOB_KEY

          [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

          [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

       

      #===================================================

      I even used :

      PARM1=0

      PARM2=1

      PARM3=2

       

      VALUE1=${SHORT_DEPLOY_JOB_NAME}

      VALUE2=${groupId}

      VALUE3=${DEPLOY_JOB_RUN_ID}

       

      VALUE1=Test_AO_1_w2k8_-v3-TAS000000012229-140212110420

      VALUE2=2135420

      VALUE2=2641656

      CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

      Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 0

      CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

      Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 1

      CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

      Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 2

      CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

      CallResult Debug: JOB_SET_DESCRIPTION: DBKey:SJobModelKeyImpl:2048473-1-4684511

        • 1. Re: Add parameters to NSHScripJob
          Rajeev Gupta

          I get the result:

          VALUE1=Test_AO_1_w2k8_-v3-TAS000000012229-140212110420

          VALUE2=2135420

          VALUE2=2641656

          CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

          Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 0

          CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

          Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 1

          CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

          Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 2

          CallResult Debug: JOB_KEY: DBKey:SJobModelKeyImpl:2048473-1-4684511

          CallResult Debug: JOB_SET_DESCRIPTION: DBKey:SJobModelKeyImpl:2048473-1-4684511

           

          #########Somehow, this was posted in first post even before i could post it.. #########

          • 2. Re: Add parameters to NSHScripJob
            Bill Robinson

            does the nsh script object itself have these parameters set already ?

            • 3. Re: Add parameters to NSHScripJob
              Rajeev Gupta

              I tried the :

              PARM1=0

              PARM2=1

              PARM3=2

               

              VALUE1=${SHORT_DEPLOY_JOB_NAME}

              VALUE2=${groupId}

              VALUE3=${DEPLOY_JOB_RUN_ID}

              but that didnt worked, so i hardcoded the values and check. Output is coming same.

              Error "Command execution failed. java.lang.IllegalArgumentException: Index points to elements not in list. List size is : 0 while index is : 0"

              Problem is, I am not able to figure out why List Size shows 0 always..

              • 4. Re: Add parameters to NSHScripJob
                Bill Robinson

                open up the NSH SCRIPT object.  goto the parameters tab.  what is there ?

                • 5. Re: Add parameters to NSHScripJob
                  Rajeev Gupta

                  Its all Blank.addparameters.JPG.jpg

                  • 6. Re: Add parameters to NSHScripJob
                    Bill Robinson

                    well then you can't add parameters to the job until the script has them defined.

                    • 7. Re: Add parameters to NSHScripJob
                      Rajeev Gupta

                      How to define that in that case?

                      • 8. Re: Add parameters to NSHScripJob
                        Rajeev Gupta

                        Wont it work this way?

                         

                        JOB_FOLDER=${JOB_FOLDER}

                        JOB_NAME=${JOB_NAME}

                         

                         

                        PARM1=0

                        PARM2=1

                        PARM3=2

                         

                         

                        VALUE1="${SHORT_DEPLOY_JOB_NAME}"

                        VALUE2="${groupId}"

                        VALUE2="${DEPLOY_JOB_RUN_ID}"

                         

                         

                        blcli_execute NSHScriptJob clearNSHScriptParameterValuesByGroupAndName ${JOB_FOLDER} "${JOB_NAME}" >> nul && blcli_storeenv JOB_KEY

                            [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

                            [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

                         

                         

                        blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOB_FOLDER}" "${JOB_NAME}" "$PARM1" "$VALUE1" >> nul && blcli_storeenv JOB_KEY

                            [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

                            [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

                         

                        blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOB_FOLDER}" "${JOB_NAME}" "$PARM2" "$VALUE2" >> nul && blcli_storeenv JOB_KEY

                            [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

                            [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

                         

                        blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName "${JOB_FOLDER}" "${JOB_NAME}" "$PARM3" "$VALUE3" >> nul && blcli_storeenv JOB_KEY

                            [[ ${DEBUG} = "true" ]] && [ -n "${JOB_KEY}" ] && echo "CallResult Debug: JOB_KEY: ${JOB_KEY}"

                            [ -z "${JOB_KEY}" ] && { echo "20"; exit 20 }

                        • 9. Re: Add parameters to NSHScripJob
                          Bill Robinson

                          You can use the gui and add them right from that screen.  Or there should be blcli commands in the NSHScript namespace to define them.

                          • 10. Re: Add parameters to NSHScripJob
                            Bill Robinson

                            because the parameter needs to be defined on the script, not the job.

                            • 11. Re: Add parameters to NSHScripJob

                              You need add the parameters in Depot-->NSHScript.. for example:Screenshot - 13_02_2014 , 18_30_32.jpg
                              And configure the parameter...

                              Screenshot - 13_02_2014 , 18_32_58.jpg

                               

                              After making the script, when you create the NSH Job in Parameters appears your parameters:

                               

                              Screenshot - 13_02_2014 , 18_35_58.jpg

                               

                              Regards,

                              1 of 1 people found this helpful
                              • 12. Re: Add parameters to NSHScripJob
                                Raja Mohan

                                Just adding the command to do in batch in case someone else is looking for it like me.


                                blcli NSHScript addNSHScriptParameterByGroupAndName depot-folder-name nsh-script-name parameter-name parameter-description-in-double-quotes parameter-flag


                                blcli NSHScript addNSHScriptParameterByGroupAndName /Workspace/NSHScripts samplenshscript Parameter1 "Enter Parameter 1 for the script" 7


                                • 1 = parameter accepts value
                                • 2 = value must not be empty at run time
                                • 4 = value is editable

                                 

                                Simply add the number to achieve your desired result

                                Example

                                3 = accept a value and it must not be empty at run time

                                5 = accept a value and editable

                                6 = value not be empty and editable

                                7 = accept a value, not be empty and editable