Ronaldo Lanhellas
Ronaldo Lanhellas

Reputation: 3356

Jenkins Pipeline and jboss deploy

I'm currently using Jenkins FreeStyle Project in my project,trying to migrate to Jenkins Pipeline, but I'm facing some issues:

1) I need to commit jenkinsfile in my project, but my deploy phase is just copy from target/project.war to jboss deployment folder, as shown below:

stage('Deploy') { 
            steps {
                sh 'cp /var/lib/jenkins/workspace/project/project.war /opt/jboss/standalone/deployment/project.war'
            }
        }

The problem: currently the path is fixed and tomorrow if a change occurs and there is a need to deploy to another machine, An update should be made to the source code which should be avoided. In FreeStyle project i just update the JOB and everything works.

2) The project has 3 modules. The FreeStyle project was configured so that JOB A will call JOB B on finish. In pipeline how can this order be achieved:
- Start JOB A --> JOB B --> JOB C.

Upvotes: 1

Views: 2607

Answers (2)

BRAIEK AYEMN
BRAIEK AYEMN

Reputation: 87

you can use sshPulissher:send build artifacts over ssh enter image description here

enter image description here add this code in your jenkins pipeline enter image description here and configure your sshServer in manage jenkins enter image description here finally your war is transfert in your destination

enter image description here

Upvotes: 1

rohit thomas
rohit thomas

Reputation: 2322

You can add the following into your script

1.Issue with copying:

  • Firstly, you avoid using the actual path(Location of file in workspace) to a relative Path i.e. using project/*.war or **/*.war it will take it from the workspace itself.
  • Second, Coming to the issue that you have to change the target location like you said you have to change it FreeStyle Project :) so you have to change it in the JenkinsFile also :)

2.To call other jobs in your pipeline and the following

 build job: 'Job2', parameters: [
              new org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterValue
                  ("TARGET_NODE", "description", nodeName)
          ]

If it does not have any parameter remove that section out.

There is something called Jenkins workflow which provides more power and control if your interested in it, you can look it up here https://dzone.com/refcardz/continuous-delivery-with-jenkins-workflow?chapter=1

Upvotes: 1

Related Questions