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

上一篇:判断一个链表是否是回文结构


下一篇:斐讯n1进入u盘启动