I created this pipeline with Jenkins in my project. Now I need to deploy the project to the server with FTP by using this code :
bat 'git ftp init --user xxxxxx--passwd xxxxxxxftp://193.141.64.96/public_html'
but it does not upload anything to the server. What's the problem? How can I upload my project with Jenkins and FTP?
pipeline {
agent any;
parameters{
choice(name: 'CHOICE', choices: ['One', 'Two', 'Three'], description: 'Pick something')
booleanParam(name:'executeTests',defaultValue:true,description:'')
}
triggers {
pollSCM('*/1 * * * *')
}
environment {
ACCESS_KEY_FTP_USERNAME = credentials('FTP_FILE_UPLOAD_USERNAME');
ACCESS_KEY_FTP_PASSWORD = credentials(' FTP_FILEUPLOAD_PASSWORD');
}
stages {
stage('Install npm') {
steps {
bat 'npm install'
}
post {
always {
echo 'Start npm install'
}
failure {
echo 'fail operation npm installr'
mail body: 'Error in npm install ', subject: 'Build failed!', to: 'kiadr9372@gmail.com'
}
success {
echo 'Success npm install'
}
}
}
stage('Test') {
when {
expression {
params.executeTests
}
}
steps{
echo 'Testing the application'
// echo "Testing Version ${NEW_VERSION}"
}
post {
always {
echo 'Success npm install'
}
failure {
echo 'fail operation npm installr'
mail body: 'Error in npm install ', subject: 'Build failed!', to: 'kiadr9372@gmail.com'
}
success {
echo 'Success npm install'
}
}}
stage('Build Project Develop') {
when {
branch 'publish'
}
parallel {
stage('build') {
steps {
bat 'npm run build '
}
}
stage('build B') {
steps {
echo ACCESS_KEY_FTP_USERNAME
echo ACCESS_KEY_FTP_PASSWORD
}
}
}
post {
always {
echo 'Success Build Project'
}
failure {
echo 'fail operation Build Project'
mail body: 'Error in Build Project ', subject: 'Build failed!', to: 'kiadr9372@gmail.com'
}
success {
echo 'Success Build Project'
mail body: 'Build Success ', subject: 'Build Success!', to: 'kiadr9372@gmail.com'
}
}
}
stage('Deploy Project (Test - Develop)') {
when {
branch 'publish'
}
steps {
dir('dist')
{
dir('TestCICD')
{
bat 'npm run build '
bat 'git ftp init --user xxxxxx--passwd xxxxxxxftp://193.141.64.96/public_html'
}
}
}
post {
always {
echo 'Success Build Project'
}
failure {
echo 'fail operation Build Project'
mail body: 'Error in Build Project ', subject: 'Build failed!', to: 'kiadr9372@gmail.com'
}
success {
echo 'Success Build Project'
mail body: 'Build Success ', subject: 'Build Success!', to: 'kiadr9372@gmail.com'
}
}
}
stage('Build Project Realase') {
when {
branch 'master'
}
steps {
bat label: '', script: 'ng build --prod '
}
post {
always {
echo 'Success Build Project'
}
failure {
echo 'fail operation Build Project'
mail body: 'Error in Build Project ', subject: 'Build failed!', to: 'kiadr9372@gmail.com'
}
success {
echo 'Success Build Project'
mail body: 'Build Success ', subject: 'Build Success!', to: 'kiadr9372@gmail.com'
}
}
}
}
}