Jenkins build number does not match number on Archiva

I have a Jenkins instance that automatically uploads artifacts to a remote Archiva repository. The artifacts uploaded include the build number, but it is only incrementing the builds sequentially so a failed Jenkins build causes the build numbers to become off. For example, my first build of MyProject uploads MyProject-1.jar to Archiva. If the next build fails, and then the third build succeeds, the artifact uploaded will be MyProject-2.jar, even though it was the third build on Jenkins. Is there a way to link these two build numbers for better tracking?

I am using Apache Archiva 2.2.0 and Jenkins 2.263.1

How to divide array of strings and store the strings in to 3 equal arrays in groovy jenkins pipeline

i am trying to create a groovy script in jenkins pipeline script and I want to loop array of strings and store strings in to 3 equal arrays dynamically

Example:

def arr=['test1','test2','test3','test4','test5','test6','test7',.....]
to
def arr1=['test1','test2','test3']
def arr2=['test4','test5','test6']
def arr3=['test7','test8']

Can any one please help

tls – Is HTTPS meaningful for Jenkins Docker container behind Nginx?

I have a Docker Compose setup that starts up Nexus, Jenkins and Nginx containers. All calls to Jenkins and Nexus must pass through Nginx. I accomplish this by only port forwarding the Nginx container. The Nexus and Jenkins container ports are merely exposed towards the Docker network.

This is my (simplified) docker-compose.yml:

version: '3.7'
services:
  nexus:
    build: ./nexus/.
    expose:
      - 8081
  jenkins:
    build: ./jenkins/.
    expose:
      - 8080
      - 50000  // no longer needed if Jenkins does not need HTTPS
    depends_on:
      - nexus
  nginx:
    image: nginx:1.19.5
    ports:
      - 80:80  // will also need to port forward 443:443 for HTTPS
    depends_on:
      - nexus
      - jenkins

My nginx.conf (again simplified):

http {
    upstream docker-jenkins {
        server jenkins:8080;
    }
    upstream docker-nexus {
        server nexus:8081;
    }

    server {
        server_name  jenkins.homenetwork.dns;

        location / {
            proxy_pass http://docker-jenkins;
        }
    }

    server {
        server_name  nexus.homenetwork.dns;

        location / {
            proxy_pass http://docker-nexus;
        }
    }
}

I am using this on my home network and will allow BitBucket to trigger jobs from Jenkins (through Nginx!). This means that the port must be externally accessible. Obviously Nginx will need to encrypt the incoming urls with HTTPS. So the expected addresses are https://jenkins.homenetwork.dns and https://nexus.homenetwork.dns with the HTTP versions redirecting to HTTPS.

The question is, do I need to setup Nexus and Jenkins with a SSL certificate? They are included in many tutorials for setting up Jenkins and Nexus, but the network traffic between Jenkins/Nexus and Nginx should only be visible from the machine that’s hosting the Docker containers. Do I run a security risk somehow by not encrypting the traffic between the Docker containers?

Jenkins – Not scanning any remote branches

Newly setup jenkins isn’t scanning any branches. I tried the global creds and multipipeline creds as well. The creds are regular http username and passwords.

The repo is a fork of another repo.

enter image description here

Here is the log:

Started
[Tue Dec 08 16:12:29 UTC 2020] Starting branch indexing...
 > git --version # timeout=10
 > git --version # 'git version 2.11.0'
using GIT_ASKPASS to set credentials 
 > git ls-remote --symref -- https://gitlab.com/myusername/techworld-js-docker-demo-app.git # timeout=10
 > git rev-parse --is-inside-work-tree # timeout=10
Setting origin to https://gitlab.com/myusername/techworld-js-docker-demo-app.git
 > git config remote.origin.url https://gitlab.com/myusername/techworld-js-docker-demo-app.git # timeout=10
Fetching & pruning origin...
Fetching upstream changes from origin
 > git --version # timeout=10
 > git --version # 'git version 2.11.0'
 > git config --get remote.origin.url # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress --prune -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
[Tue Dec 08 16:12:36 UTC 2020] Finished branch indexing. Indexing took 7 sec
Finished: SUCCESS

jenkins – Error from server (NotFound): deployments.apps

I am trying to do blue green deployments for AKS using Jenkins. I am currently following this document
https://docs.microsoft.com/en-us/azure/developer/jenkins/deploy-to-aks-using-blue-green-deployment-pattern

When I run the pipeline I am getting the following error:

kubectl –kubeconfig=kubeconfig delete deployment todoapp-deployment-blue
Error from server (NotFound): deployments.apps “todoapp-deployment-blue” not found
What exactly does this error mean and how do I resolve it.

Jenkins Github Branch Source Plugin Failing with Github Token after today’s Github auth changes

I am currently facing an issue with Jenkins <> Github integration due to today’s Github auth changes deprecating user/pass auth and the current Github branch source plugin.

Deprecation info: https://developer.github.com/changes/2020-02-14-deprecating-password-auth/#removal

Plugin: https://github.com/jenkinsci/github-branch-source-plugin

  • Jenkins: 2.249.3
  • Github branch source plugin 2.9.1 (latest)
  • This jenkins install is private only (not public facing)
  • The repo being accessed is private (not public facing)
  • The Github token has full repo access

Issue:

The plugin forces user/pass auth which Github no longer accepts. The instructions state to put the TOKEN in the password field but it still complains after I’ve done that:

The API can’t be accessed using username/password authentication

https://developer.github.com/changes/2020-02-14-deprecating-password-auth/#removal

Instructions state: “Only username/password credentials are supported” and instructs to add the Token in the password field (screenshot shows this)

The attached screenshot shows the debacle clearly:

enter image description here

Questions to ServerFault:

  • Am I entering the token wrong for the credentials? I’ve tried:
    • a null user, with the token as the password
    • The token as the user & pass
    • The token description as the user, with the token as the password
  • Normally I would submit a Github issue to a developer about an app issue. However since there is no “Issues” component to submit issues to the plugin developer, I wanted to ask my question here, in case others have hit this.

jenkins – How to setup AWS infra so https://www.myjenkins.com and https://www.myjenkins.com:8888 goes to different servers?

I’m trying to setup a test Jenkins blue/green site so https://www.jenkins.com goes to the production (blue) site, while https://www.jenkins.com:8888 goes to the test (green) site. Can I set this up with a single ALB? If not how can I set this up?

I know I’d need 2 EC2s running each the blue- and green-jenkins service. I’m fuzzy on how to route traffic given a port on the URL.

jenkins – SonarQube for different java versions

we are using sonarqube which is installed on cloud premises with the following configuraitons:

sonarqube version: Version 7.9.4 (build 35981)
Java Code Quality and Security Code Analyzer for Java :6.3.2 (build 22818)
kotlin plugin: detekt: 2.3.0

now the question is we are having projects which uses java11 and one more project(Android) which uses Kotlin java8.

we are able to integrate with the projects using java11, however when we are trying to integrate with Kotlin project which uses java8, it is giving me the following error SonarScanner will require Java 11 to run starting in SonarQube 8.x.

spring boot – manage Jenkins frontend and backend parties

I have a two part application on springboot and angular, I want to deploy this application using continuous integration with Jenkins,
in other words I want to make this application exploitable for front-end clients, this is the devops part of my graduation project, and my question here is how to deploy the two parts and make them communicate with each other through a server application for example, I have micro services in the backend (eureka, zuul, ribbon …)
tools: git, Jenkins, Gitlab …

docker – Como permitir que meu container SQL Server criado pelo contaner do jenkins consiga obter a visualização de arquivos .bak do meu host?

Gostaria de que meu container SQL Server criado pelo contaner do jenkins consiga obter a visualização de arquivos .bak do meu host e assim possa efetuar a restauração de alguns bancos. Como consigo realizar esta tarefa?

  1. Detalhes do meu ambiente:

Eu utilizo windows 10 pro e o WSL (windows subsystem for linux).
Criei um container jenkins no docker que monta minha infra local de ambiente dev.
Ele é o ambiente ‘host’ do container do Sql Server e de quase toda a minha infra.
Sobre os daemons do host e do container eu efetuei bind entre esses daemons.

docker-compose do meu jenkins

version: "3.7"

#Volume to sql-server-container-dev
volumes:
  jenkins-dev:
    name: jenkins-dev

services:
  
  jenkins-dev-service:
    container_name: jenkins-dev
    hostname: windows-host
    build:
      context: .
      dockerfile: Dockerfile  
    image: jenkins-image-dev
    ports:
      - "8080:8080"
    volumes:
     #Bind o daemon docker do host para o container
     - '//var/run/docker.sock:/var/run/docker.sock'

     #Dependencia abstrata
     - 'C:/Projetos/infra_agil/jenkins:/jenkins'

docker compose do sql server

version: "3.7"

networks: 
   sql-server-network:
     driver: bridge
     
volumes:
  jenkins-dev:
    external: true

services:
  # Habilite Filesharing se não o sql server não irá subir
  sql-server-db:
    container_name: sql-server-container-dev
    build:
      context: .
      dockerfile: Dockerfile
    image: sql-server:2019
    volumes:
      - type: volume
        source: jenkins-dev
        target: /backups
    ports: 
        - "1433:1433"
    networks:
      - sql-server-network 

O docker-compose do meu jenkins está localizado:

C:Projetosinfra_agiljenkins

O docker-compose do sqlserver está localizado:

C:Projetosinfra_agiljenkinsinfra_comumsql-server

Os arquivos de backup estão localizados:

C:Projetosinfra_agiljenkinsdatabasebackups

Abaixo uma imagem que apresenta a localização destes arquivos.

Árvore do diretório

Já fiz diversos testes. Em um deles eu consegui fazer um ‘bind’ entre a pasta backups do host – jenkins – e do sql server mas o container do sql-server não conseguia ver os arquivos dentro da pasta, apenas o jenkins conseguia ver.