您的位置:首页 > 其它

Pipeline load and load from git

2018-04-05 23:44 567 查看

load

https://www.sourcefield.nl/post/jenkins-pipeline-tutorial/

 

 

node {
// Use the shell to create the file 'script.groovy'
sh '''echo '
def hello(name) {
echo "Hello ${name} from script"
}
return this
' > script.groovy'''
def script = load 'script.groovy'
script.hello('Roy')
}

 

 

load from git

 

Loading a script from another Git repository

This requires the Pipeline Remote File Loader plugin. The example assumes you have a repository somewhere that contains a

Pipeline.groovy
file, which you want to download to your Jenkins workspace.

  1. Go to Manage Jenkins > Manage Plugins and install

    Pipeline Remote File Loader
    (without restart)

  2. Configure a Pipeline job and set the Pipeline script to the following:

 

node {
stage 'Load pipeline script'
def pipeline = fileLoader.fromGit(
'Pipeline.groovy',
'https://bitbucket.org/your-account/your-build-scripts.git',
'master', // use a branch or tag
'your-account-credential-id', // ID from Credentials plugin
''
)
checkout scm
pipeline.execute()
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐