Похожие чаты

There is a Jenkins pipeline job. It does the following


Stage 1. clones git repo.
Stage 2. Using matrix for multiple services.
- Prepare env variable stage
- run code linting
- run test
- build docker
- push image to ecr

Git repo have multiple services. We have to build and publish image to ecr for each service. I used matrix here and the variable is service_name with values service_a, service_b.

at prepare env step, variables I am creating by calling jenkins shared libs function. The jenkins shared libs function creates ecr_repo_name variable by concatenation of project_name, region and service_name.

Problem - the environment variables ecr_repo_name have the same value for all repos. So the image that is built is tagged wrong.

If I create this variable in the stage itself by not calling the jenkins shared lib function, it works.

One more thing... I am building docker image by using the shared libs function only.

How do I make it work using shared libs?
I have put in a lot of time in creating the shared libs function for each activity and now it does not work with matrix.

1 ответов

42 просмотра

It seems like you're facing an issue with Jenkins shared libraries when using them in a matrix. Shared libraries in Jenkins are a powerful tool for sharing Groovy code between different Jenkins jobs. They are stored in Git repositories, and their functionalities are at the user's disposal. The problem you're facing might be due to the scope of the variables in the shared library. When you're using a matrix, each axis of the matrix runs in its own environment, and changes to environment variables in one axis do not affect the others. This could be why the ecr_repo_name variable has the same value for all repos. Here are a few suggestions that might help: 1. Scope of Variables: Ensure that the variables you're defining in the shared library are not global. If they are, they might be getting overwritten in each run of the matrix. 2. Shared Library Structure: Verify that your shared library is structured correctly. The src directory should look like a standard Java source directory structure, and the vars directory should host script files that are exposed as a variable in Pipelines. 3. Library Loading: You might need to load the shared library in each stage of the matrix. This can ensure that the library and its functions are available in the scope of that stage. 4. Legacy SCM Option: Some users have reported that selecting the "Legacy SCM" option for shared libraries in the Jenkins -> Manage Jenkins -> Configure System menu resolved similar issues.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта