<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>npm &amp;mdash; Jerry of the Week</title>
    <link>https://write.in0rdr.ch/tag:npm</link>
    <description>ˈdʒɛri - Individual who sends life against the grain no matter the consequences</description>
    <pubDate>Fri, 17 Apr 2026 09:06:47 +0000</pubDate>
    <item>
      <title>Bump NPM dependencies with Updatecli</title>
      <link>https://write.in0rdr.ch/bump-npm-dependencies-with-updatecli</link>
      <description>&lt;![CDATA[I built a new Jenkins pipeline based on Updatecli for updating the NPM packages in my hobby project MyHeats.&#xA;&#xA;#updatecli #pipeline #jenkins #myheats #nodejs #npm&#xA;!--more--&#xA;&#xA;I was looking for a way to automatically bump the version of the npm dependencies (package.json) whenever there is an update available. This is also important for security reasons (e.g., have a look at the output of npm audit from time to time to see the recent security issues in the dependencies).&#xA;&#xA;I was looking into Renovate and Dependabot, but neither of these scratched my itch of simple automatic dependency updates.&#xA;&#xA;A coworker suggested me to try Updatecli and it fits my workflows perfectly well. The Jenkins example on the projects website got me started. So I created a Jenkins shared library function to run my own build, which includes npm to perform the version bumps:&#xA;&#xA;A class to describe the updatecli stages: https://code.in0rdr.ch/jenkins-lib/file/src/Updatecli.groovy.html&#xA;&#xA;The scripted pipeline in the repository of the application loads the library and performs the version bumps to a new branch:&#xA;&#xA;The Jenkinsfile that makes use of the updatecli groovy library: https://code.in0rdr.ch/myheats/file/Jenkinsfile.html&#xA;&#xA;I did not even have to configure Updatecli a lot, because the autodiscovery feature automatically detects that this is a npm repository/project. The final version of my pipeline includes all the git/scm steps in the updatecli.d/default.yaml configuration file:&#xA;&#xA;Updatecli configuration file: https://code.in0rdr.ch/myheats/file/updatecli.d/default.yaml.html&#xA;&#xA;First I tried to perform the SCM/git steps in Jenkins checkout and sh steps. But I noticed it could be much sleeker by defining the SCM/git settings in the Updatecli config file directly. This way, updatecli takes care of the clone/checkout/push steps. Here the extract from my previous pipeline with the &#34;manual git steps&#34; for comparison:&#xA;&#xA;// alternative approach I did not pursue any further&#xA;sh &#39;&#39;&#39;&#xA;git config --global user.name &#34;$GITAUTHORNAME&#34;&#xA;git config --global user.email &#34;$GITAUTHOREMAIL&#34;&#xA;&#39;&#39;&#39;&#xA;&#xA;dir(&#34;myyheats.git-$BUILDNUMBER&#34;) {&#xA;  // checkout update branch in new directory&#xA;  checkout scmGit(&#xA;      extensions: [localBranch(&#34;$branch&#34;)],&#xA;      userRemoteConfigs: [[url: &#39;https://git.in0rdr.ch/myheats.git&#39;]]&#xA;  )&#xA;&#xA;  updatecli.run(&#39;apply&#39;)&#xA;&#xA;  // commit changes&#xA;  sh &#39;&#39;&#39;&#xA;  git add -u&#xA;  git commit -m &#34;chore(updatecli-$BUILDNUMBER): bump node modules&#34;&#xA;  git push -f -u origin &#34;$branch&#34;&#xA;  &#39;&#39;&#39;&#xA;}&#xA;&#xA;I definitely like the updatecli configuration better, since it keeps the actual pipeline tidy. Also, I like how you can use the {{ requiredEnv &#34;GIT_PASSWORD&#34; }} configuration in updatecli to read secrets from the environment. The Git credentials are sourced from OpenBao with Nomad workload identities.&#xA;&#xA;I hope the post is helpful for anyone that would like to give updatecli a try or would like to configure a similar Jenkins pipeline.&#xA;&#xA;div style=&#34;text-align:center; font-size: 0.8em&#34;&#xD;&#xA;a href=&#34;https://write.in0rdr.ch/feed&#34;&amp;#128732; RSS/a | a href=&#34;https://m.in0rdr.ch/in0rdr&#34;&amp;#128024; Fediverse/a | a href=&#34;https://chat.in0rdr.ch/#/guest?join=p0c@conference.in0rdr.ch&#34;&amp;#128172; XMPP/a&#xD;&#xA;/div]]&gt;</description>
      <content:encoded><![CDATA[<p>I built a new Jenkins pipeline based on <a href="https://www.updatecli.io">Updatecli</a> for updating the NPM packages in my hobby project <a href="https://myheats.p0c.ch">MyHeats</a>.</p>

<p><a href="https://write.in0rdr.ch/tag:updatecli" class="hashtag"><span>#</span><span class="p-category">updatecli</span></a> <a href="https://write.in0rdr.ch/tag:pipeline" class="hashtag"><span>#</span><span class="p-category">pipeline</span></a> <a href="https://write.in0rdr.ch/tag:jenkins" class="hashtag"><span>#</span><span class="p-category">jenkins</span></a> <a href="https://write.in0rdr.ch/tag:myheats" class="hashtag"><span>#</span><span class="p-category">myheats</span></a> <a href="https://write.in0rdr.ch/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://write.in0rdr.ch/tag:npm" class="hashtag"><span>#</span><span class="p-category">npm</span></a>
</p>

<p>I was looking for a way to automatically bump the version of the npm dependencies (<code>package.json</code>) whenever there is an update available. This is also important for security reasons (e.g., have a look at the output of <code>npm audit</code> from time to time to see the recent security issues in the dependencies).</p>

<p>I was looking into <a href="https://github.com/renovatebot/renovate">Renovate</a> and <a href="https://github.com/dependabot">Dependabot</a>, but neither of these scratched my itch of simple automatic dependency updates.</p>

<p>A coworker suggested me to try <a href="https://www.updatecli.io">Updatecli</a> and it fits my workflows perfectly well. The <a href="https://www.updatecli.io/docs/automate/jenkins">Jenkins example</a> on the projects website got me started. So I created a <a href="https://www.jenkins.io/doc/book/pipeline/shared-libraries">Jenkins shared library function</a> to run my own build, which includes <code>npm</code> to perform the version bumps:</p>
<ul><li>A class to describe the updatecli stages: <a href="https://code.in0rdr.ch/jenkins-lib/file/src/Updatecli.groovy.html">https://code.in0rdr.ch/jenkins-lib/file/src/Updatecli.groovy.html</a></li></ul>

<p>The scripted pipeline in the repository of the application loads the library and performs the version bumps to a new branch:</p>
<ul><li>The Jenkinsfile that makes use of the updatecli groovy library: <a href="https://code.in0rdr.ch/myheats/file/Jenkinsfile.html">https://code.in0rdr.ch/myheats/file/Jenkinsfile.html</a></li></ul>

<p>I did not even have to configure Updatecli a lot, because the <a href="https://www.updatecli.io/docs/core/autodiscovery">autodiscovery feature</a> automatically detects that this is a npm repository/project. The final version of my pipeline includes all the git/scm steps in the <code>updatecli.d/default.yaml</code> configuration file:</p>
<ul><li>Updatecli configuration file: <a href="https://code.in0rdr.ch/myheats/file/updatecli.d/default.yaml.html">https://code.in0rdr.ch/myheats/file/updatecli.d/default.yaml.html</a></li></ul>

<p>First I tried to perform the SCM/git steps in Jenkins <code>checkout</code> and <code>sh</code> steps. But I noticed it could be much sleeker by defining the SCM/git settings in the Updatecli config file directly. This way, updatecli takes care of the clone/checkout/push steps. Here the extract from my previous pipeline with the “manual git steps” for comparison:</p>

<pre><code class="language-java">// alternative approach I did not pursue any further
sh &#39;&#39;&#39;
git config --global user.name &#34;$GIT_AUTHOR_NAME&#34;
git config --global user.email &#34;$GIT_AUTHOR_EMAIL&#34;
&#39;&#39;&#39;

dir(&#34;myyheats.git-$BUILD_NUMBER&#34;) {
  // checkout update branch in new directory
  checkout scmGit(
      extensions: [localBranch(&#34;$branch&#34;)],
      userRemoteConfigs: [[url: &#39;https://git.in0rdr.ch/myheats.git&#39;]]
  )

  updatecli.run(&#39;apply&#39;)

  // commit changes
  sh &#39;&#39;&#39;
  git add -u
  git commit -m &#34;chore(updatecli-$BUILD_NUMBER): bump node modules&#34;
  git push -f -u origin &#34;$branch&#34;
  &#39;&#39;&#39;
}
</code></pre>

<p>I definitely like the <a href="https://code.in0rdr.ch/myheats/file/updatecli.d/default.yaml.html">updatecli configuration</a> better, since it keeps the actual pipeline tidy. Also, I like how you can use the <code>{{ requiredEnv &#34;GIT_PASSWORD&#34; }}</code> configuration in updatecli to read secrets from the environment. The Git credentials are sourced from OpenBao with Nomad workload identities.</p>

<p>I hope the post is helpful for anyone that would like to give updatecli a try or would like to configure a similar Jenkins pipeline.</p>

<div style="text-align:center; font-size: 0.8em">
<a href="https://write.in0rdr.ch/feed">🛜 RSS</a> | <a href="https://m.in0rdr.ch/in0rdr">🐘 Fediverse</a> | <a href="https://chat.in0rdr.ch/#/guest?join=p0c@conference.in0rdr.ch">💬 XMPP</a>
</div>
]]></content:encoded>
      <guid>https://write.in0rdr.ch/bump-npm-dependencies-with-updatecli</guid>
      <pubDate>Fri, 26 Jul 2024 20:50:19 +0000</pubDate>
    </item>
  </channel>
</rss>