중첩된 if 문 실행 오류

중첩된 if 문 실행 오류

쉘 스크립트에 중첩된 if 문을 작성하려고 합니다. 스크립트는 다음과 같습니다.

#select the snapshot or release    
if  [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
then
    $SELECT_SNAPSHOT_VERSION
    echo "Snapshot Selected"

elif [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ] 
then
     $SELECT_RELEASE_VERSION
     echo "Release Selected"

     if [ "$Server_Selection" == "192.168.94.139" ]
     then
         selectDevSnap;
         echo "deployed to 139"

     elif [ "$Server_Selection" == "192.168.94.140" ]
     then
         selectProdRel
         echo "deployed to 140"

      else 
          echo "ERROR"

      fi

else 
      echo "Error Selection"
fi

이 스크립트에서는 "192.168.94.140" 부분만 실행됩니다. 이 문제를 어떻게 해결할 수 있습니까?

답변1

이것은 나에게 효과적입니다.

relVersion="$SELECT_RELEASE_VERSION_ARTIFACT_URL" 

snapVersion="$SELECT_SNAPSHOT_VERSION_ARTIFACT_URL"         

source=(/var/lib/jenkins/workspace/Proj_Frontend_Parameterized_Deployment/*.tgz) 

selectDevSnap(){

           devDestination=([email protected]:/usr/share/nginx/PROJFRONTEND/proj.com/)

           wget "$snapVersion"
           scp $source $devDestination
           ssh [email protected] "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"

            }


selectProdRel(){

           prodDestination=([email protected]:/usr/share/nginx/PROJFRONTEND/proj.com/)

           wget "$relVersion"
           scp $source $prodDestination
           ssh [email protected] "cd /usr/share/nginx/PROJFRONTEND/proj.com/ ; tar xvf *.tgz"

            }

             if  [ "$SELECT_SNAP_OR_REL_VERSION" == "Snapshots" ]
            then
                   $SELECT_SNAPSHOT_VERSION
                   echo "Snapshot Selected"

                if [ "$SELECT_SNAP_OR_REL_VERSION" == "Releases" ] 
                then
                   $SELECT_RELEASE_VERSION
                   echo "Release Selected"
                fi

                if [ "$Server_Selection" == "192.168.94.139" ]
                then
                    selectDevSnap;
                    echo "deployed to 139"

                elif [ "$Server_Selection" == "192.168.94.140" ]
                then
                   selectProdRel
                   echo "deployed to 140"

                else 
                   echo "ERROR"

                fi

            else 
                echo "Error Selection"

            fi

관련 정보