pipeline {
  agent {
    label "swarm"
  }
  environment {
    git_url=""
  }
  parameters {
    string(
      name: "build_repo",
      defaultValue: "prod",
      description: "Repository to build from. To not build - set parameter to 'none'."
    )
    string(
      name: "service_update",
      defaultValue: "",
      description: "Services to update - i.e. info_node or/and info_node-api"
    )
  }
  stages {
    stage("Build") {
      when { expression { build_repo != "none" } }
      steps {
        echo "Building with repo $build_repo"
        sh '''pwd
              ls'''
      }
    }
    stage("Update") {
      when { expression { service_update != "" } }
      steps {
        echo "Updating .$service_update."
        script {
          for (String item : service_update.split()) {
            echo "Updating $item"
          }
        }
        sh 'ls'
      }
    }
  }
  post {
    always {
      echo "It's always good to be here."
    }
    changed {
      echo "Something changed..."
    }
    failure {
      echo "Oh, snap. It's failed again"
    }
    success {
      echo "Fine !!! It's SUCCESS !!!"
    }
    unstable {
      echo "Unstable ...."
    }
    aborted {
      echo "Hmmm... It's aborted"
    }
  }
}