Skip to content

Commit

Permalink
few fixes for container crash
Browse files Browse the repository at this point in the history
  • Loading branch information
githubofkrishnadhas committed Jul 6, 2024
1 parent 26fd0f8 commit a458620
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ RUN latest_release=$(curl -s https://api.github.com/repos/jenkinsci/plugin-insta
curl -fsSL "${download_url}" -o $JENKINS_HOME/jenkins-plugin-manager.jar
# copy plugins.yaml file for installing plugins using jenkins cli
COPY plugins.yaml ${JENKINS_HOME}/plugins.yaml
# Copy user.groovy to /usr/share/jenkins/ref/init.groovy.d/ where will setup the default admin user and password:
COPY user.groovy /usr/share/jenkins/ref/init.groovy.d/
# Copy user.groovy,number_of_executors.groovy to /usr/share/jenkins/ref/init.groovy.d/ where jenkins init scripts will run
COPY *.groovy /usr/share/jenkins/ref/init.groovy.d/
# Configuration as code and set as a environment variable
COPY ./config-as-code.yaml $JENKINS_HOME/config-as-code.yaml
ENV CASC_JENKINS_CONFIG=$JENKINS_HOME/config-as-code.yaml
Expand Down
27 changes: 0 additions & 27 deletions config-as-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,4 @@ credentials:
id: "${GITHUB_APP_ID}"
privateKey: "${GITHUB_APP_KEY}"


# Providing default permission for users through `authenticated` group that can login to jenkins
jenkins:
# setting basic nuqmber of job executors in jenkins master as 6
numExecutors: 6
authorizationStrategy:
globalMatrix:
entries:
- group:
name: "authenticated"
permissions:
- "Agent/Build"
- "Agent/Configure"
- "Agent/Create"
- "Credentials/Create"
- "Credentials/Update"
- "Credentials/View"
- "Job/Build"
- "Job/Cancel"
- "Job/Configure"
- "Job/Create"
- "Job/Move"
- "Job/Read"
- "Overall/Read"
- "View/Configure"
- "View/Create"
- "View/Read"
# ref https://www.roger.ml/p/jenkins-ci-github-app-authentication
13 changes: 13 additions & 0 deletions number_of_executors.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import jenkins.model.Jenkins

// parameter to tweak default number of executors
Integer numberOfExecutors = 6

// get Jenkins instance
def jenkins = Jenkins.getInstance()

// set the number of slaves
jenkins.setNumExecutors(numberOfExecutors)

// save current Jenkins state to disk
jenkins.save()
1 change: 1 addition & 0 deletions user.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if(!(jenkins.getAuthorizationStrategy() instanceof GlobalMatrixAuthorizationStra

def user = jenkins.getSecurityRealm().createAccount(env.JENKINS_USER, env.JENKINS_PASS)
user.save()
// provide admin access to jenkins_user which is passed by user
jenkins.getAuthorizationStrategy().add(Jenkins.ADMINISTER, env.JENKINS_USER)

jenkins.save()

0 comments on commit a458620

Please sign in to comment.