Execute shell script using jenkins pipeline and capture status and output of script in pipeline

Поділитися
Вставка

КОМЕНТАРІ • 7

  • @srinivasaraju8399
    @srinivasaraju8399 Місяць тому

    Can you please make a video java application cicd pipeline please
    Your video really awesome ❤🎉

    • @technologytheoryhandson863
      @technologytheoryhandson863  Місяць тому

      Thank you very much for the nice comment..Sure I will make a video on end to end CICD pipeline..but I need to cover topics on other required tools before that... meanwhile you can go through the video for pipeline for java build ua-cam.com/video/XtRVSZZO4Vc/v-deo.htmlsi=7KaRatQ4iHcRPvvS

  • @kratikatripathi1166
    @kratikatripathi1166 9 місяців тому

    I need to use the output of one project as a input parameter for other project
    for eg
    in Project A
    there is build step of execute shell, which will execute a shell script, simply listing the content of the directory mentioned with the script
    now in Project B
    i need those output of project A as one of the parameter in Project B
    Please advice

    • @technologytheoryhandson863
      @technologytheoryhandson863  9 місяців тому

      Generally if it is the same pipeline, we can assign the output to a groovy variable and use it in another stage...but for a separate job,my advice is to write the output of first job in a file and read that file content in another job

    • @kratikatripathi1166
      @kratikatripathi1166 9 місяців тому

      @@technologytheoryhandson863 i tried this, but when i am trying to read that file it gives me error of permission denied.. although i explicitly copied the output.txt file from project A workspace to the workspace of project B and have full permission

  • @snemana1
    @snemana1 8 місяців тому

    Can you run this script only once and collect both status and stdout same time and print it in the pipeline? You ran it twice in this demo.

    • @technologytheoryhandson863
      @technologytheoryhandson863  8 місяців тому

      As of now, jenkins does not provide option to use returnStatus and returnStdout in same command. However we can use shell inbuilt redirection operators to achieve this. You can try the below command which is provided in stackoverflow.
      def stdoutAndStatus = sh script: 'set +x ; ls -a 2>&1 && echo "status:$?" || echo "status:$?" ; exit 0', returnStdout: true
      echo "stdoutAndStatus: >$stdoutAndStatus