Answers: <p>I had a requirement for a job to run manually and only select users should run the job. Below is the rule:</p>
  <pre><code>    - if: $CI_PIPELINE_SOURCE == &quot;web&quot; &amp;&amp; $GITLAB_USER_LOGIN == &quot;&lt;User Name&gt;&quot;
        when: manual
      - when: never
  </code></pre>
  <p>Alternatively you can use GitLab API's to check user access level and run the job based on that condition (But this will be part of the script, Community version GitLab does not provide this kind of rules).
  Furthermore you can add rules based on branch names:</p>
  <pre><code>    - if: $CI_COMMIT_BRANCH == &quot;develop&quot; || $CI_COMMIT_BRANCH  =~ /^release/
        when: always
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2024-04-08T13:14:20.730Z
Answers: 2024-04-08T13:20:48.700Z
Answers: 2024-04-08T13:20:48.700Z
Answers: Arslan Zaidi
Answers: <p>We are using protected environment and protected variables in CICD. Only mainteiners have access to them.</p>
  <p>So anyone could trigger pipeline, but it was failed, cause there no access to k8s, and other resources</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-04-15T06:31:37.300Z
Answers: Your answer seems unclear to me. I am not using the Pipeline to create a container in the K8 here.
Answers: Ajay
Answers: CC BY-SA 4.0
Answers: 2024-04-15T10:18:25.170Z
Answers: Here you can read about protected environments in gitlab ci  
  https://docs.gitlab.com/ee/ci/environments/protected_environments.html
  I think it could be usefull
  If its not helpful, then i not fully understand your question
Answers: Yamnii Arsenii
Answers: CC BY-SA 4.0
Answers: 2024-04-14T04:57:00.150Z
Answers: 2024-04-14T04:57:00.150Z
Answers: Yamnii Arsenii
Body: <p>I have a requirement: Only people with the <strong>Maintainer</strong> access in the repository should have access to trigger the Gitlab pipeline jobs in the respective repository. The developers in the repositories have <strong>Write</strong> access to the repository and can also trigger the GitLab pipeline jobs. I need a workaround to restrict the triggering in higher environment branches.</p>
  
Tags: <gitlab><pipeline>
Title: Restrict access to trigger the GitLab pipeline job
UserDisplayName: Ajay
ThreadText: # Restrict access to trigger the GitLab pipeline job
  
  (Asked by: username_0 on 2024-04-05)
  
  I have a requirement: Only people with the **Maintainer** access in the repository should have access to trigger the Gitlab pipeline jobs in the respective repository. The developers in the repositories have **Write** access to the repository and can also trigger the GitLab pipeline jobs. I need a workaround to restrict the triggering in higher environment branches.
  
  **Tags:** gitlab, pipeline
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-04-08. Score: 1 | Accepted answer
  
  I had a requirement for a job to run manually and only select users should run the job. Below is the rule:
  
  ```
      - if: $CI_PIPELINE_SOURCE == "web" && $GITLAB_USER_LOGIN == "<User Name>"
        when: manual
      - when: never
  
  ```
  
  Alternatively you can use GitLab API's to check user access level and run the job based on that condition (But this will be part of the script, Community version GitLab does not provide this kind of rules).
  Furthermore you can add rules based on branch names:
  
  ```
      - if: $CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH  =~ /^release/
        when: always
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2024-04-14. Score: 0
  
  We are using protected environment and protected variables in CICD. Only mainteiners have access to them.
  
  So anyone could trigger pipeline, but it was failed, cause there no access to k8s, and other resources
  
  > **Comments:**
  > **username_0**: Your answer seems unclear to me. I am not using the Pipeline to create a container in the K8 here.  
  > **username_2**: Here you can read about protected environments in gitlab ci   https://docs.gitlab.com/ee/ci/environments/protected_environments.html I think it could be usefull If its not helpful, then i not fully understand your question  
  
  ---
  
  