詹金斯管道 - 远程构建

时间:2018-05-21 18:54:37

标签: jenkins build jenkins-pipeline

我是詹金斯的新手,请帮助我。我想默认在远程服务器上构建作业。但是正在努力建立在主人身上。

我有以下管道脚本。 --Test_Pipeline ---

pipeline {
    agent any
    stages {
        stage('Test1') {
            steps {
                build job: 'Job1', 
                     parameters: [
                                    string(name: 'Environment', value: 'dev'),
                                    string(name: 'ProjectName', value: 'Temp'),
                                    string(name: 'JobName', value: 'Job1'),
                                    string(name: 'Parameters', value: 'Dummy')
                                ]
            }
        }
    }
}

- 当我没有传递“参数”时,它正在远程构建作业。但是使用参数,它建立在master之上。

使用参数:

由上游项目“Test_Pipeline”开始编号21

originally caused by:
 Started by user Temp1
[EnvInject] - Loading node environment variables.
Building on master in workspace E:\Program Files (x86)\Jenkins\jobs\Job1\workspace
No emails were triggered.
[workspace] $ sh -xe C:\Users\ZPAPPB~1\AppData\Local\Temp\hudson7083850686294271347.sh
+ /opt/ibm/scripts/bin/Exec.ksh run Temp Job1 Dummy
-----

没有参数:

由上游项目“Test_Pipeline”内部版本号22开始

originally caused by:
 Started by user Temp1
[EnvInject] - Loading node environment variables.
Building remotely on appserver01 in workspace /opt/jenkins/workspace/JobExecution
No emails were triggered.
[JobExecution] $ /bin/sh -xe /tmp/hudson2555136363794702914.sh
+ /opt/ibm/scripts/bin/Exec.ksh run def1 Job2 Dummy

1 个答案:

答案 0 :(得分:0)

我不认为它是远程构建的,因为参数。 agent { label 'appserver01' }允许Jenkins在任何代理人中建立工作。

将其设置为if($stmt = mysqli_prepare($link, $sql)){ 会将构建限制为该节点。

有关其他选项,请参阅Method 2