<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591439#M4722153</link>
    <description>&lt;P&gt;Bingo!&lt;/P&gt;&lt;P&gt;The problem was that I assumed, that the arguments mapping is performed by the SAP Project Piper and a script becomes the arguments just like in case of the regular CLI-call, e.g. npm_config_*.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 18:38:01 GMT</pubDate>
    <dc:creator>MikeB</dc:creator>
    <dc:date>2022-11-17T18:38:01Z</dc:date>
    <item>
      <title>How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaq-p/12591431</link>
      <description>&lt;P&gt;I'm trying to run the npm-script from the Jenkins pipeline via the SAP Project Piper's &lt;STRONG&gt;npmExecuteScripts:&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;npmExecuteScripts:
    runScripts: ["testScript"]&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;That works! Now, I want to pass some arguments to my script.&lt;BR /&gt;According to the Project Piper documentation, there is a property &lt;A href="https://www.project-piper.io/steps/npmExecuteScripts/#scriptoptions" target="_blank"&gt;scriptOptions&lt;/A&gt;, which cares about passing arguments to the called script:&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;Options are passed to all runScripts calls separated by a '--'. './piper npmExecuteScripts --runScripts ci-e2e --scriptOptions '--tag1' will correspond to 'npm run ci-e2e -- --tag1'&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;Unfortunately, I can't figure out what is the proper syntax for that command.&lt;BR /&gt;I've tried several combinations of using &lt;STRONG&gt;scriptOptions&lt;/STRONG&gt;, e.g.:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;scriptOptions: ["myArg"]
scriptOptions: ["myArg=myVal"]
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; and many others, but still no desired outcome!&lt;/P&gt;
  &lt;P&gt;How can I call an npm-script and pass arguments / parameters to the script using the Project Piper's &lt;STRONG&gt;npmExecuteScripts&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 17:25:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaq-p/12591431</guid>
      <dc:creator>MikeB</dc:creator>
      <dc:date>2022-11-03T17:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591432#M4722146</link>
      <description>&lt;P&gt;Did you try adding dashes?&lt;/P&gt;&lt;P&gt;scriptOptions: ['--myArg']&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 20:28:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591432#M4722146</guid>
      <dc:creator>jamie_cawley</dc:creator>
      <dc:date>2022-11-03T20:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591433#M4722147</link>
      <description>&lt;P&gt;Hey, &lt;SPAN class="mention-scrubbed"&gt;jamie.cawley&lt;/SPAN&gt; !&lt;/P&gt;&lt;P&gt;On the Jenkins side, I've tried:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;npmExecuteScripts:
  runScripts: ["testScript"]
  scriptOptions: ["--montreal"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And on the npm-script side, I've tried various options:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"testParams": "echo '*** My city: '$PIPER_scriptOptions' ***'",
"testParams": "echo '*** My city: '{$PIPER_scriptOptions}' ***'",
"testParams": "echo '*** My city: '${PIPER_scriptOptions}' ***'",
"testParams": "echo '*** My city: $PIPER_scriptOptions ***'",
"testParams": "echo '*** My city: {$PIPER_scriptOptions} ***'",
"testParams": "echo '*** My city: ${PIPER_scriptOptions} ***'",
"testParams": "echo '*** My city: '$npm_config_PIPER_scriptOptions' ***'",
"testParams": "echo '*** My city: '{$npm_config_PIPER_scriptOptions}' ***'",
"testParams": "echo '*** My city: '${npm_config_PIPER_scriptOptions}' ***'",
"testParams": "echo '*** My city: $npm_config_PIPER_scriptOptions ***'",
"testParams": "echo '*** My city: {$npm_config_PIPER_scriptOptions} ***'",
"testParams": "echo '*** My city: ${npm_config_PIPER_scriptOptions} ***'",
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But none of them returns the desired result:&lt;/P&gt;&lt;P&gt;*** My city: montreal ***&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 17:22:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591433#M4722147</guid>
      <dc:creator>MikeB</dc:creator>
      <dc:date>2022-11-04T17:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591434#M4722148</link>
      <description>&lt;P&gt;What do you see in the log files when npm is running? Have you tried using $npm_config_montreal when it has a value?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 13:37:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591434#M4722148</guid>
      <dc:creator>jamie_cawley</dc:creator>
      <dc:date>2022-11-09T13:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591435#M4722149</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;jamie.cawley&lt;/SPAN&gt;, I've tried &lt;STRONG&gt;$npm_config_montreal&lt;/STRONG&gt; and the result:&lt;/P&gt;&lt;P&gt;*** My city:  *** --montreal&lt;/P&gt;&lt;P&gt;The log file:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;info  npmExecuteScripts - run-script testParams
info  npmExecuteScripts - running command: npm run testParams -- --montreal
info  npmExecuteScripts - 
info  npmExecuteScripts - &amp;gt; myApp@1.0.0 testParams /var/apphome/.../.jenkins/workspace/myApp_master@2
info  npmExecuteScripts - &amp;gt; echo '*** My city: '${npm_config_montreal}' ***' "--montreal"
info  npmExecuteScripts - 
info  npmExecuteScripts - *** My city:  *** --montreal&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Nov 2022 13:37:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591435#M4722149</guid>
      <dc:creator>MikeB</dc:creator>
      <dc:date>2022-11-11T13:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591436#M4722150</link>
      <description>&lt;P&gt;Try setting the param with a value.&lt;/P&gt;&lt;P&gt;--montreal=test&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 20:01:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591436#M4722150</guid>
      <dc:creator>jamie_cawley</dc:creator>
      <dc:date>2022-11-15T20:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591437#M4722151</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;jamie.cawley&lt;/SPAN&gt;, I've tried that already, unfortunately, no wanted outcome.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jenkins Pipeline configuration:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;npmExecuteScripts:
	runScripts: ["testParams1", "testParams2", "testParams3", "testParams4", "testParams5", "testParams6"]
	scriptOptions: ["--city=Montreal"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;package.json:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;"scripts": {
	"testParams1": "echo \"*** My city: '$city' ***\"",
	"testParams2": "echo \"*** My city: '${city}' ***\"",
	"testParams3": "echo \"*** My city: '$npm_config_city' ***\"",
	"testParams4": "echo \"*** My city: '${npm_config_city}' ***\"",
	"testParams5": "echo \"*** My city: '{$npm_config_city}' ***\"",
	"testParams6": "echo \"*** My city: '{npm_config_city}' ***\""
}&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, none of the scripts above provided the desired outcome: *** My city: 'Montreal' ***.&lt;/P&gt;&lt;P&gt;The used SAP Project Piper version: &lt;STRONG&gt;1.147.0&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 12:25:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591437#M4722151</guid>
      <dc:creator>MikeB</dc:creator>
      <dc:date>2022-11-16T12:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591438#M4722152</link>
      <description>&lt;P&gt;Ok I think because there is a proceeding "--" they are not set to the config values. Can you just use them in the script you are trying to run?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;scriptOptions: ["city=Montreal"]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in the script&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;const myArgs = process.argv.slice(2);&lt;BR /&gt;console.log(myArgs[0]);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 16:10:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591438#M4722152</guid>
      <dc:creator>jamie_cawley</dc:creator>
      <dc:date>2022-11-16T16:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass arguments / parameters to the npm-script using npmExecuteScripts?</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591439#M4722153</link>
      <description>&lt;P&gt;Bingo!&lt;/P&gt;&lt;P&gt;The problem was that I assumed, that the arguments mapping is performed by the SAP Project Piper and a script becomes the arguments just like in case of the regular CLI-call, e.g. npm_config_*.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 18:38:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-pass-arguments-parameters-to-the-npm-script-using-npmexecutescripts/qaa-p/12591439#M4722153</guid>
      <dc:creator>MikeB</dc:creator>
      <dc:date>2022-11-17T18:38:01Z</dc:date>
    </item>
  </channel>
</rss>

