在jenkis管道中找不到这样的文件

时间:2019-05-24 13:40:59

标签: jenkins jenkins-pipeline jenkins-groovy

这是我的常规文件 时间戳{   节点('cf_slave'){     结帐scm

stage('Read the file') {
    def PWD = pwd()
    withEnv(["prj_option=${params.project}"]) {
        def response =sh(returnStdout: true, script: 'sh \'jenkins/security/get_values.sh\'')
        }
    }

这是我的get_values.sh文件


echo "The project option is:" $prj_option

prj_name=$(echo "$prj_option" | tr '[:upper:]' '[:lower:]')
file_name="va_input_file_$prj_name.txt"

echo "The project option is:" $file_name
ls -la
chmod 775 jenkins/security/$file_name
ls -la

get_input_values() {
  file=$1
  IFS=''
  while read line
    do
    if [ `echo ${line} | grep -E -c -w "NAME_SPACE" ` -gt 0 ]; then
      NAME_SPACE=$(echo " ${line}" | cut -d'=' -f2)
      echo "The name space value is $NAME_SPACE"
    elif [ `echo ${line} | grep -E -c -w "IMAGE_NAMES" ` -gt 0 ]; then
      values=$(echo " ${line}" | cut -d'=' -f2)
      echo "THE DOCKERIMAGES are $DOCKER_IMAGES_NAMES"
    else
      echo "Please provide input for namespace and docker images to be scanned by VA_TOOl"
    fi
  done < ${file}
}


images=$(get_input_values ${file_name})

所以在这里,我的文本文件位于gitrepo的jenkins / security文件夹下,但不幸的是,我收到此错误:

16:05:28 + sh jenkins/security/get_values.sh
16:05:28 jenkins/security/get_values.sh: 16: jenkins/security/get_values.sh: cannot open va_input_file_icp.txt: No such file```

1 个答案:

答案 0 :(得分:0)

不幸的是,詹金斯(https://issues.jenkins-ci.org/browse/JENKINS-51245)中有一张票证,已被复制为这张票证(https://issues.jenkins-ci.org/browse/JENKINS-27413

JENKINS-27413于2015年提出,目前仍在营业。 File Parameter在Jenkins Pipeline中似乎不起作用。但是,在Freestyle项目中使用时,它确实可以工作。虽然不理想,但如果可行,我建议您将工作更改为Freestyle项目。

相关问题