Showing posts with label jenkins. Show all posts
Showing posts with label jenkins. Show all posts

Tuesday, May 10, 2022

Docker not found when building docker image using Docker Jenkins container pipeline

 


Ref: https://localcoder.org/docker-not-found-when-building-docker-image-using-docker-jenkins-container-pipel

Solution 5:

docker run -d \
--group-add docker \
-v $(pwd)/jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(which docker):/usr/bin/docker \
-p 8080:8080 -p 50000:50000 \
jenkins/jenkins:lts

Just add option --group-add docker when docker run.


Tuesday, April 12, 2022

Jenkins delete builds older than latest 20 builds for all jobs

 Ref: https://stackoverflow.com/questions/35610053/jenkins-delete-builds-older-than-latest-20-builds-for-all-jobs

You can use the Jenkins Script Console to iterate through all jobs, get a list of the N most recent and perform some action on the others.

import jenkins.model.Jenkins
import hudson.model.Job

MAX_BUILDS = 20

for (job in Jenkins.instance.items) {
  println job.name

  def recent = job.builds.limit(MAX_BUILDS)

  for (build in job.builds) {
    if (!recent.contains(build)) {
      println "Preparing to delete: " + build
      // build.delete()
    }
  }
}

The Jenkins Script Console is a great tool for administrative maintenance like this and there's often an existing script that does something similar to what you want.

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...