Openshift在jenkinsfile中检索分支名称

时间:2018-06-01 12:30:52

标签: openshift openshift-origin openshift-3

我在bitbucket服务器上配置了webhook,指向Openshift。 我想从我的内联jenkinsfile中的webhook有效载荷中获取GIT repo url,git branch等,但我不知道如何检索它们。 (Webhook会触发构建)。

有可能吗?

这是我的BuildConfig

/**
         * Updating progress bar
         * */
        protected void onProgressUpdate(String... progress) {
            // setting progress percentage
            pDialog.setProgress(Integer.parseInt(progress[0]));
       }



/**
         * After completing background task
         * Dismiss the progress dialog
         * **/
        @Override
        protected void onPostExecute(String file_url) {
            // dismiss the dialog after the file was downloaded
            dismissDialog(progress_bar_type);


        }


}

- 谢谢

1 个答案:

答案 0 :(得分:0)

根据this stack overflow questionsome Jenkins documentation,您需要在Jenkins实例上安装git plugin。然后,您将通过GIT_BRANCHGIT_URL获得变量${env.GIT_BRANCH}${env.GIT_URL}确保您的分支名称中没有斜杠(ex release / 1.2.3),因为这会混淆Jenkins中的许多关键工具

或者作为最后的手段,在Jenkins scripted pipeline中,您可以通过参数或默认设置(例如" master")设置您自己的环境变量,如果您知道您不会更改您的分支机构常。

相关问题