全部!
我在管道代码中通过ftp使用Plugin Publisher遇到了问题。我在管道代码上方的“环境{APP_NAME ='123'}”中设置了APP_NAME。但是变量“ APP_NAME”不能被ftpPublisher掌握。
与ftpPublisher已知的BUILD_NUMBER JOB_NAME等变量相同。
任何人都可以帮助我吗?非常感谢你!!!
,我的jenkins ver是2.164.2,通过ftp ver发布是1.15。
pipeline {
environment {
APP_NAME='123'
}
......
stages {
stage('1. git pull') {
steps {
git(
branch: 'release',
credentialsId: '*****',
url : '*********',
changelog: true
)
sh "ls -lat"
}
}
stage('2. build') {
steps {
sh 'cnpm install'
sh 'bower install --allow-root'
sh 'gulp goluk:pro'
sh 'mkdir -p $APP_NAME target'
sh 'cp -rf dist/* $APP_NAME/'
sh 'tar jcvf $APP_NAME.tar.bz2 $APP_NAME/'
sh 'ls -lh'
sh 'mv $APP_NAME.tar.bz2 target/$APP_NAME.tar.bz2'
sh 'rm -rf $APP_NAME'
}
}
stage('3. send to ftp') {
steps {
sh 'printenv'
ftpPublisher(
masterNodeName: 'master' ,
paramPublish: [parameterName: ''],
alwaysPublishFromMaster: false,
continueOnError: false,
failOnError: false,
publishers: [
[ configName: 'ftpServer_250',
transfers: [
[ asciiMode: false,
cleanRemote: false,
excludes: '',
flatten: false,
makeEmptyDirs: true,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: '${APP_NAME}/$BUILD_NUMBER($BUILD_ID)',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'target/*.tar.bz2'
]
],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
]
]
)
}
}
}
}
答案 0 :(得分:0)
更改为remoteDirectory: "${APP_NAME}/$BUILD_NUMBER($BUILD_ID)"