How to configure Jenkins through yaml file

Time:2022-5-25

Install Jenkins

docker run -d --name jenkins-master -p 8080:8080 -p 50000:50000 -v /var/jenkins_home:/var/jenkins_home -v /etc/localtime:/etc/localtime --restart=always jenkinsci/blueocean

After successful startup, log in to Jenkins and the initial password path is:/var/jenkins_home/secrets/initialAdminPassword
And install Jenkins configuration as code (a.k.a. jcasc) plugin.

The jcasc plug-in supports the use of yaml filesjenkins.yamlTo configure the Jenkins instance, it does not support installing plug-ins using jcasc, so you need to use the following tools:
Docker deployment:
https://github.com/jenkinsci/docker/#preinstalling-plugins
Kubernetes deployment:
https://github.com/jenkinsci/helm-charts

After installation, enter the manage Jenkins page and find the entry of configuration as code:

How to configure Jenkins through yaml file

JCasC.png

Click “view configuration” to display the current configuration information of Jenkins instance in yaml format.

jenkins:
  agentProtocols:
  - "JNLP4-connect"
  - "Ping"
  authorizationStrategy:
    loggedInUsersCanDoAnything:
      allowAnonymousRead: false
  disableRememberMe: false
  disabledAdministrativeMonitors:
  - "jenkins.diagnostics.ControllerExecutorsNoAgents"
  labelAtoms:
  - name: "built-in"
  markupFormatter: "plainText"
  mode: NORMAL
  myViewsTabBar: "standard"
  numExecutors: 2
  primaryView:
    all:
      name: "all"
  projectNamingStrategy: "standard"
  quietPeriod: 5
  remotingSecurity:
    enabled: true
  scmCheckoutRetryCount: 0
  securityRealm:
    local:
      allowsSignup: false
      enableCaptcha: false
      users:
      - id: "admin"
        name: "admin"
        properties:
        - "apiToken"
        - favoriting:
            autofavoriteEnabled: true
        - "mailer"
        - "favorite"
        - "myView"
        - preferredProvider:
            providerId: "default"
        - "timezone"
  slaveAgentPort: 50000
  updateCenter:
    sites:
    - id: "default"
      url: "https://updates.jenkins.io/update-center.json"
  views:
  - all:
      name: "all"
  viewsTabBar: "standard"
globalCredentialsConfiguration:
  configuration:
    providerFilter: "none"
    typeFilter: "none"
security:
  apiToken:
    creationOfLegacyTokenEnabled: false
    tokenGenerationOnCreationEnabled: false
    usageStatisticsEnabled: true
  sSHD:
    port: -1
unclassified:
  bitbucketEndpointConfiguration:
    endpoints:
    - bitbucketCloudEndpoint:
        enableCache: false
        manageHooks: false
        repositoriesCacheDuration: 0
        teamCacheDuration: 0
  buildDiscarders:
    configuredBuildDiscarders:
    - "jobBuildDiscarder"
  fingerprints:
    fingerprintCleanupDisabled: false
    storage: "file"
  gitHubConfiguration:
    apiRateLimitChecker: ThrottleForNormalize
  gitHubPluginConfig:
    hookUrl: "http://192.168.255.134:8080/github-webhook/"
  gitSCM:
    addGitTagAction: false
    allowSecondFetch: false
    createAccountBasedOnEmail: false
    disableGitToolChooser: false
    hideCredentials: false
    showEntireCommitSummaryInChanges: false
    useExistingAccountWithSameEmail: false
  junitTestResultStorage:
    storage: "file"
  location:
    Adminaddress: 'no mailbox address configured< [email protected] >"
    url: "http://192.168.255.134:8080/"
  mailer:
    charset: "UTF-8"
    useSsl: false
    useTls: false
  pollSCM:
    pollingThreadCount: 10
  timestamper:
    allPipelines: false
    elapsedTimeFormat: "'<b>'HH:mm:ss.S'</b> '"
    systemTimeFormat: "'<b>'HH:mm:ss'</b> '"
tool:
  git:
    installations:
    - home: "git"
      name: "Default"
  mavenGlobalConfig:
    globalSettingsProvider: "standard"
    settingsProvider: "standard"

New profile, addsystemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"。 The default location of the file is$JENKINS_HOME/jenkins.yamlBecause the new yaml file is placed in$JENKINS_HOMEDirectory.

jenkins:
  systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"

Click “system” to make the existing configuration file effective again.

How to configure Jenkins through yaml file

Jenkins.png

reference resources:https://github.com/jenkinsci/configuration-as-code-plugin/

Recommended Today

ffmpeg pushes video with RTP protocol

docker build environment docker pull abdulachik/ffmpeg.js:latest docker run -it -p 8080:8080 -v /Users/workspace/Downloads/ffmpeg_wasm:/tmp –privileged=true abdulachik/ffmpeg.js:latest /bin/bash cd /tmp Process overview camera-&gt;ffmpeg-&gt;encode to h264 video-&gt;pass to h264 decoder-&gt;play(You can also push the video directly to RTMP protocol after encoding, and the local decoding and playback is only for testing) ffmpeg encodes video stream (from camera) to […]