Execute Shell script from workspace on remote machine after build successful (Jenkins)

The scenario is – I have a job A which runs my ant script and packages the artifact’s for me.

I am also using parametrized Triggered plug in to Trigger my “Job B” which will deploy my artifact on remote machine.

  • Jenkins: could not create Android emulator failed to parse AVD config file
  • Export command in Jenkins pipeline
  • Jenkins Build Flow Plugin sequentially chain multiple jobs in parallel
  • Trigger a Jenkins Build based on Commit Author?
  • Setting up webhooks with an independent git server?
  • Jenkins Buildflow plugin: how to make variable numbers of jobs in parallel?
  • The job A is working fine and also Job B.

    The tasks that i have to perform with Job B are

    1. GIT checkout (which contains my deployment scripts) (successfully doning).
    2. Copying artifacts from previous build to Remote machine. (successfully doing)
    3. Run shell script on remote machine(script present in workspace folder )- Facing issues.

    I browsed various plug ins for the same but no one is allowing me to run shell script after , “SCP to remote machine” which is present in Post build action.

    I would like to execute the same sequence, however if you guys have any other suggestions please share.

    Thanks in Advance.!

  • Creating Maven assembly with files from different Git branches
  • Trigger Jenkins job on GitHub PUSH to specific branch
  • SonarQube exclude Maven module
  • Jenkins: how to run two different Sonar analysis in a Maven build?
  • Jenkins Git integration - How to disable SSL certificate validation
  • SonarQube not picking up Unit Test Coverage
  • 2 Solutions collect form web for “Execute Shell script from workspace on remote machine after build successful (Jenkins)”

    As part of Publish Over SSH Plugin, you can execute a script after the files had been copied over.

    • Under Post-build Actions
    • Add Send build artifacts over SSH
    • Select a preconfigured server (done in global configuration)
    • Select files to copy from workspace
    • Enter Exec command
      1. If one of the files you copy is your shell script, you can enter it here as an “exec command”

    To solve my query i used Jenkins SSH Plugin. This provides a configuration tab where i can add multiple hosts and after that used them in my job level configuration.

    Link to Plugin

    you get priviledge to execute shell script on remote host as pre build step or post build step.

    Git Baby is a git and github fan, let's start git clone.