I'm using the new Jenkins2 pipeline to build a composed project with:
- node frontend
- php backend
both are in different repositories hence, the need to use pipeline to sync them, compile, and prepare them to deploy. I cannot find a simple way to deploy using FTP.
My script looks something like this:
node {
// uncomment these 2 lines and edit the name 'node-4.4.5' according to what you choose in configuration
def nodeHome = tool name: 'NodeJS 7.2.1', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
env.PATH = "${nodeHome}/bin:${env.PATH}"
stage("front") {
dir('front') { // switch to subdir
git url: ...
sh "npm install"
sh "npm run build --prod"
sh "cp -R * ../dist"
}
}
stage("back") {
dir('back') {
git url: ...
sh 'curl -sS https://getcomposer.org/installer | php'
sh 'php composer.phar install'
sh "cp -R * ../dist"
}
}
stage("upload via ftp") {
// IM NOT SURE WHAT TO DO HERE
}
}
UPDATE 2016-12-16
To clarify what I need is a way to run something similar to "Publish via FTP" like older versions of Jenkins.
So your question is how to use Linux command line to upload a file via ftp? I think it was already solved here
The Jenkins Publish Over FTP plugin has Pipeline support as of version 1.15.
A snippet from my Jenkinsfile that sends some files to our server:
I could not get get the Jenkins Publish Over FTP plugin to work at all so I decided to use shell scripts which work. Below is a snippet using lftp. If you do not have that installed, either install it or use vanilla ftp.
This will only send things to FTP if there is a tag in git.
Install
ncftp
on the computer and run this command in Jenkins:(Taken from Can I upload an entire folder using FTP? on Super User)