0

Hi all Iam using Jenkins to perform initial installation. Here is my script:

# Setup installation repository
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum makecache fast

# Install
yum install docker-ce
# Run
systemctl start docker
# Test
docker run hello-world
#Add user to the group
usermod -aG docker root

How can I have Jenkins fail if my docker run hello-world fails for any reason. Does anybody know the script for that ?? Iam running the shell script from my "Execute Shell " placeholder in my Jenkins master where it executes everything on my slave node. Is this a good idea ??

Nabeel A.Rahman
  • 181
  • 3
  • 14
  • 2
    You need to make your bash script fail if any line fails. Try `set -e`? https://stackoverflow.com/questions/1378274/in-a-bash-script-how-can-i-exit-the-entire-script-if-a-certain-condition-occurs/1379904#1379904 – mkasberg Oct 20 '17 at 18:22
  • ok this really helps !! – Nabeel A.Rahman Oct 20 '17 at 22:29
  • `set -e` causes the script to fail if certain commands have a non-zero exit code, which is not always an indication of failure. You are better off doing your own error handling. – chepner Oct 22 '17 at 00:10

0 Answers0