How can I trigger another job from a jenkins pipeline (jenkinsfile) with GitHub Org Plugin?

前端 未结 5 712
执念已碎
执念已碎 2020-11-28 18:38

How can I trigger build of another job from inside the Jenkinsfile?

I assume that this job is another repository under the same github organization, on

5条回答
  •  自闭症患者
    2020-11-28 18:57

    First of all, it is a waste of an executor slot to wrap the build step in node. Your upstream executor will just be sitting idle for no reason.

    Second, from a multibranch project, you can use the environment variable BRANCH_NAME to make logic conditional on the current branch.

    Third, the job parameter takes an absolute or relative job name. If you give a name without any path qualification, that would refer to another job in the same folder, which in the case of a multibranch project would mean another branch of the same repository.

    Thus what you meant to write is probably

    if (env.BRANCH_NAME == 'master') {
        build '../other-repo/master'
    }
    

提交回复
热议问题