De Wiki inetshell
Saltar a: navegación, buscar

Restablecer password[editar]

https://stackoverflow.com/questions/6988849/how-to-reset-jenkins-security-settings-from-the-command-line

  • Editar ${JENKINS_HOME}/users/admin/config.xml
<passwordHash>#jbcrypt:$2a$10$razd3L1aXndFfBNHO95aj.IVrFydsxkcQCcLmujmFQzll3hcUrY7S</passwordHash>
  • Reiniciar servicio jenkins
  • Acceder con el password "test" (Sin comillas)
  • Cambiar password

Master[editar]

  • docker-compose.yml:
version: '2'

services:
  master:
    image: jenkins/jenkins:lts
    ports:
      - "8080:8080"
      - "50000:50000"
    volumes:
      - "/jenkins/data:/var/jenkins_home:Z"

Linux Slave[editar]

https://hub.docker.com/r/jenkins/jnlp-slave/

  • docker-compose.yml:
version: '2'

services:
  slave:
    image: jenkins/jnlp-slave
    environment:
      - JENKINS_URL=http://192.168.1.1:8080
      - JENKINS_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      - JENKINS_AGENT_NAME=slave-linux
      - JENKINS_AGENT_WORKDIR=/home/jenkins/agent

Pipeline[editar]

https://jenkins.io/blog/2017/02/07/declarative-maven-project/

http://docs.groovy-lang.org/next/html/documentation/

Limitar trabajos concurrentes[editar]

https://stackoverflow.com/questions/41492688/how-to-limit-jenkins-concurrent-multibranch-pipeline-builds

pipeline {
    options {
        disableConcurrentBuilds()
    }
}

Tipos de parametro[editar]

  • Choice:

https://github.com/jenkinsci/pipeline-model-definition-plugin/wiki/Parametrized-pipelines

SSL[editar]

https://github.com/t4skforce/jenkins-ssl

Archivos de configuracion[editar]

https://wiki.jenkins.io/display/JENKINS/Administering+Jenkins

Jenkins con NGINX[editar]

https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy https://gist.github.com/coffeencoke/3885343

Usar prefix: https://wiki.jenkins.io/display/JENKINS/Jenkins+behind+an+NGinX+reverse+proxy

    location /jenkins/ {
        sendfile                   off;
        proxy_pass                 http://jenkins:8080/jenkins/;
        proxy_redirect             off;
        proxy_set_header           Host $host;
        proxy_set_header           X-Real-IP $remote_addr;
        proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_max_temp_file_size   0;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;

        proxy_http_version         1.1;
        proxy_request_buffering    off;

        client_max_body_size       10m;
        client_body_buffer_size    128k;
    }

Usar credenciales dentro de pipeline[editar]

https://jenkins.io/doc/pipeline/steps/credentials-binding/

Window Jenkins Agent Docker[editar]

http://techcommunity.softwareag.com/web/guest/pwiki/-/wiki/Main/Windows+Docker+container+as+Jenkins+slaves

Recuperar credencial guardada[editar]

https://looselytyped.com/blog/2017/10/25/uncovering-passwords-in-jenkins/

  • Acceder al directorio de Jenkins y buscar archivo "credentials.xml"
  • En Jenkins, ejecutar el siguiente comando de Groovy, cambiando el valor del string al del archivo credentials.xml:
import hudson.util.Secret;
println Secret.decrypt("{AQAAABAAAAAgyqp9mI73xTYaYkaMRNolxwxR+X0qev7q6Hb3KcchbM9VA5ERj0RG1Nrl/aFw7haU}");

Webhooks[editar]

  1. Genera un usuario para github
  2. Genera el API token para usuario github (En el ejemplo, API_TOKEN)
  3. Asigna los privilegios Overall:Read y Job:Read
  4. En el job, entra a la configuracion
  5. En la seccion Build Triggers | Trigger builds remotely, genera un token (En el ejemplo, JOB_TOKEN)
  6. Para ejecutar el job, usa el siguiente comando:
curl "https://USER:[email protected]/job/JOB-NAME/build?token=JOB_TOKEN"

Usar diccionarios y maps[editar]

https://stackoverflow.com/questions/42770775/how-to-define-and-iterate-over-map-in-jenkinsfile

https://stackoverflow.com/questions/37594635/why-an-each-loop-in-a-jenkinsfile-stops-at-first-iteration

https://stackoverflow.com/questions/48286829/obtaining-groovy-value-from-map-given-computed-key-for-jenkins


Definir timezone[editar]

https://wiki.jenkins.io/display/JENKINS/Change+time+zone

docker run ... -e JAVA_OPTS=-Duser.timezone=America/Mexico_City jenkins