Jenkins Pipeline使用File parameter上传文件并保存到workspace

Jenkins Pipeline直接使用File parameter,无法将文件上传到当前job的workspace下面,需要通过调用第三方jenkinsci-unstashParam-library库实现,方法如下:

sharedlibraries地址:https://github.com/janvrany/jenkinsci-unstashParam-library

unzip jenkinsci-unstashParam-library-master.zip -d ./
mv jenkinsci-unstashParam-library-master jenkinsci-unstashParam-library
cd /data/tools/jenkinsci-unstashParam-library 
git init
git add .
git commit -m "init"

git status 
/usr/bin/git ls-remote -h /data/tools/jenkinsci-unstashParam-library 

 

jenkins  configure system

Jenkins Pipeline使用File parameter上传文件并保存到workspace

 

 

在pipeline中引用sharedlibraries

@Library(jenkinsci-unstashParam-library) _
import hudson.model.*;

pipeline {
    agent {
        label master
    }

    environment {
    
        HARBOR_CREDS = credentials(149fd0b9-5156-4e46-b6bf-196049cb464a)

    }
    
    parameters {
        
        file(name: jenkins.war, description: 输入上传war包)

    }

 

 

 

 

 

原文链接:https://blog.csdn.net/qq_31977125/article/details/118101841

Jenkins Pipeline使用File parameter上传文件并保存到workspace

上一篇:selenium控制的爬虫被网站识别出来


下一篇:【Java 泛型】使用上下边界通配符解决泛型擦除问题