<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/atom.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Posts tagged: ci-cd</title>
  <id>https://waylonwalker.com/tags/ci-cd/atom.xml</id>
  <updated>2022-12-07T13:09:37Z</updated>
  <subtitle>All posts with the tag &#34;ci-cd&#34;</subtitle>
  <link href="https://waylonwalker.com/tags/ci-cd/" rel="alternate" type="text/html"></link>
  <link href="https://waylonwalker.com/tags/ci-cd/atom.xml" rel="self" type="application/atom+xml"></link>
  <author>
    <name>Waylon Walker</name>
  </author>
  <generator uri="https://github.com/WaylonWalker/markata-go">markata-go</generator>
  <entry>
    <title>dash e your github docker actions</title>
    <id>https://waylonwalker.com/fail-ci-scripts/</id>
    <updated>2022-12-07T13:09:37Z</updated>
    <published>2022-12-07T13:09:37Z</published>
    <link href="https://waylonwalker.com/fail-ci-scripts/" rel="alternate" type="text/html"></link>
    <summary type="text">Give github actions the -e flag in the shebang so they fail on any one command failure. Otherwise each line will set the exit status, but only the last one...</summary>
    <content type="html">&lt;p&gt;Give github actions the -e flag in the shebang &lt;code&gt;#!&lt;/code&gt; so they fail on any one&#xA;command failure. Otherwise each line will set the exit status, but only the&#xA;last one will be passed to ci.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;cp&#34;&gt;#!/bin/bash -e&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;what-is--e&#34;&gt;What is -e &lt;a href=&#34;#what-is--e&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;The -e flag to the bash command allows your script to exit immediately if any&#xA;command within the script returns a non-zero exit status. This can be useful&#xA;for ensuring that your script exits with an error if any of the commands it&#xA;runs fail, which can help you identify and debug issues in your script. For&#xA;example, if you have a script that runs several commands and one of those&#xA;commands fails, the script will continue running without the -e flag, but will&#xA;exit immediately if the -e flag is present. This can make it easier to&#xA;troubleshoot your script and ensure that it runs correctly.&lt;/p&gt;&#xA;&lt;h2 id=&#34;solution-for-windows&#34;&gt;Solution for Windows &lt;a href=&#34;#solution-for-windows&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;In windows the solution is not quite as simple. You can define a function in a&#xA;Windows batch script that wraps an if statement to check the exit status of a&#xA;command and handle any errors that may have occurred. Here is an example of how&#xA;you might define a function called “check_error” that does this:&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;nl&#34;&gt;check_error&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;errorlevel&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;k&#34;&gt;echo&lt;/span&gt; An error occurred!&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;k&#34;&gt;exit&lt;/span&gt; /b 1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To use this function in your script, you would simply call it after running a&#xA;command, like this:&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;some_command&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;call&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;nl&#34;&gt;check_error&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This would run the “some_command” and then call the “check_error” function to&#xA;check the exit status and handle any errors that may have occurred. This&#xA;approach allows you to reuse the error-checking logic in your script, which can&#xA;make it easier to write and maintain.&lt;/p&gt;&#xA;</content>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
  <entry>
    <title>automate your deploys</title>
    <id>https://waylonwalker.com/automate-your-deploys/</id>
    <updated>2020-02-07T12:08:00Z</updated>
    <published>2020-02-07T12:08:00Z</published>
    <link href="https://waylonwalker.com/automate-your-deploys/" rel="alternate" type="text/html"></link>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
</feed>