admin管理员组

文章数量:1122832

I have a CI pipeline which is triggered whenever a user creates a merge request. In addition, I can run it on a specific branch that I give as a parameter. I then checkout the branch and run the unit tests/E2E tests on it.

givenGitBranch = user decides to run tests on a specific branch

gitlabSourceBranch = branch of the merge request

stage('Checkout branch') {
            steps {
                updateGitlabCommitStatus name: 'build', state: 'running'
                cleanWs()
                echo "Given Git Branch: ${params.givenGitBranch}"
                echo "GitLab Source Branch: ${env.gitlabSourceBranch}"
                checkout([
                    $class: 'GitSCM',
                    branches: [([ $class: 'BranchSpec',
                                name: params.givenGitBranch ?:   env.gitlabSourceBranch])],
                    userRemoteConfigs: [[url: scm.getUserRemoteConfigs()[0].getUrl(),
                                        credentialsId:'random-creds']]
                ])
            }
        }

However, when I want to rerun a failed pipeline via Blue Ocean, the parameters are initialized as null and this stage fails. Is there a way to access the parameter values when I rerun the pipeline?

I tried reviewing Jenkins docs, pipeline options and nothing was relevant to the solution.

I have a CI pipeline which is triggered whenever a user creates a merge request. In addition, I can run it on a specific branch that I give as a parameter. I then checkout the branch and run the unit tests/E2E tests on it.

givenGitBranch = user decides to run tests on a specific branch

gitlabSourceBranch = branch of the merge request

stage('Checkout branch') {
            steps {
                updateGitlabCommitStatus name: 'build', state: 'running'
                cleanWs()
                echo "Given Git Branch: ${params.givenGitBranch}"
                echo "GitLab Source Branch: ${env.gitlabSourceBranch}"
                checkout([
                    $class: 'GitSCM',
                    branches: [([ $class: 'BranchSpec',
                                name: params.givenGitBranch ?:   env.gitlabSourceBranch])],
                    userRemoteConfigs: [[url: scm.getUserRemoteConfigs()[0].getUrl(),
                                        credentialsId:'random-creds']]
                ])
            }
        }

However, when I want to rerun a failed pipeline via Blue Ocean, the parameters are initialized as null and this stage fails. Is there a way to access the parameter values when I rerun the pipeline?

I tried reviewing Jenkins docs, pipeline options and nothing was relevant to the solution.

Share Improve this question edited yesterday Omer Lerner asked yesterday Omer LernerOmer Lerner 112 bronze badges New contributor Omer Lerner is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0
  1. I don't suggest blue ocean anymore since they are no longer maintained. The graph view plugin is all you need for a lightweight graph view.
  2. The rerun button is actually treated as 'replay' when you wanted the 'rebuild' button instead.
  3. In the normal view, a rebuild should fill the parameters (applies the env as well). As long as you expose the parameters in the first place.

Hope that helps

本文标签: cicdRerun Jenkins Pipeline with parameters from the last buildStack Overflow