Skip to content

Commit acca8ce

Browse files
committed
03-cd/01-jenkins updates
1 parent 5b21fcb commit acca8ce

30 files changed

+67
-46
lines changed
Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,32 @@
1-
FROM jenkinsci/blueocean:latest
1+
# Warning: Outdated image
2+
# FROM jenkinsci/blueocean:latest
23

3-
USER root
4-
5-
# install node
6-
RUN apk add --update nodejs npm
4+
FROM jenkins/jenkins:lts-jdk11
75

8-
# install docker-compose via python
9-
RUN apk update \
10-
&& apk add --no-cache python3 \
11-
&& apk add --no-cache --virtual .docker-compose-deps python3 python3-dev py3-pip libffi-dev openssl-dev gcc libc-dev make cargo rust \
12-
&& pip3 install docker-compose # buildkit
6+
USER root
137

14-
# .NET Core deps
15-
RUN apk add --no-cache \
16-
ca-certificates \
17-
icu-libs \
18-
krb5-libs \
19-
libgcc \
20-
libintl \
21-
libssl1.1 \
22-
libstdc++ \
23-
zlib
8+
# install docker-cli
9+
RUN apt-get update && apt-get install -y lsb-release
10+
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
11+
https://download.docker.com/linux/debian/gpg
12+
RUN echo "deb [arch=$(dpkg --print-architecture) \
13+
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
14+
https://download.docker.com/linux/debian \
15+
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
16+
RUN apt-get update && apt-get install -y docker-ce-cli
2417

25-
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT="true" \
26-
PATH="${PATH}:/root/.dotnet"
18+
# install docker-compose
19+
RUN curl --fail -sL https://api.github.com/repos/docker/compose/releases/latest| grep tag_name | cut -d '"' -f 4 | tee /tmp/compose-version \
20+
&& mkdir -p /usr/lib/docker/cli-plugins \
21+
&& curl --fail -sL -o /usr/lib/docker/cli-plugins/docker-compose https://github.com/docker/compose/releases/download/$(cat /tmp/compose-version)/docker-compose-$(uname -s)-$(uname -m) \
22+
&& chmod +x /usr/lib/docker/cli-plugins/docker-compose \
23+
&& ln -s /usr/lib/docker/cli-plugins/docker-compose /usr/bin/docker-compose \
24+
&& rm /tmp/compose-version
2725

28-
# .NET Core SDK
29-
# see https://github.com/dotnet/dotnet-docker/blob/main/src/sdk/3.1/alpine3.14/amd64/Dockerfile
30-
RUN dotnet_sdk_version=3.1.201 \
31-
&& wget -O dotnet.tar.gz https://dotnetcli.azureedge.net/dotnet/Sdk/$dotnet_sdk_version/dotnet-sdk-$dotnet_sdk_version-linux-musl-x64.tar.gz \
32-
&& dotnet_sha512='9a8f14be881cacb29452300f39ee66f24e253e2df947f388ad2157114cd3f44eeeb88fae4e3dd1f9687ce47f27d43f2805f9f54694b8523dc9f998b59ae79996' \
33-
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
34-
&& mkdir -p /usr/share/dotnet \
35-
&& tar -C /usr/share/dotnet -oxzf dotnet.tar.gz \
36-
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet \
37-
&& rm dotnet.tar.gz \
38-
# Trigger first run experience by running arbitrary cmd
39-
&& dotnet help
26+
# install node
27+
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
28+
&& apt-get install -y nodejs
4029

4130
USER jenkins
31+
32+
RUN jenkins-plugin-cli --plugins "blueocean:1.25.8 docker-workflow:521.v1a_a_dd2073b_2e"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
docker:
3+
image: docker:dind
4+
container_name: jenkins-docker
5+
privileged: true
6+
restart: unless-stopped
7+
environment:
8+
DOCKER_TLS_CERTDIR: /certs
9+
volumes:
10+
- docker_certs:/certs/client
11+
- jenkins_home:/var/jenkins_home
12+
13+
jenkins:
14+
build: .
15+
container_name: jenkins-blueocean
16+
restart: unless-stopped
17+
environment:
18+
DOCKER_HOST: tcp://docker:2376
19+
DOCKER_CERT_PATH: /certs/client
20+
DOCKER_TLS_VERIFY: 1
21+
volumes:
22+
- docker_certs:/certs/client:ro
23+
- jenkins_home:/var/jenkins_home
24+
ports:
25+
- 8080:8080
26+
- 50000:50000
27+
28+
volumes:
29+
docker_certs:
30+
jenkins_home:

03-cd/01-jenkins/02-construyendo-pipelines-reusables/00_clean_code_refactor_pipelines.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Creamos `01/demo1/1.1/Jenkinsfile`
2222
pipeline {
2323
agent any
2424
environment {
25-
VERSION = sh([ script: 'cd ./01/src && npx -c \'echo $npm_package_version\'', returnStdout: true ]).trim()
25+
VERSION = sh([ script: 'cd ./01/solution && npx -c \'echo $npm_package_version\'', returnStdout: true ]).trim()
2626
VERSION_RC = "rc.2"
2727
}
2828
stages {
@@ -38,7 +38,7 @@ pipeline {
3838
}
3939
stage('Build') {
4040
steps {
41-
dir('./01/src') {
41+
dir('./01/solution') {
4242
echo "Building version ${VERSION} with suffix: ${VERSION_RC}"
4343
sh '''
4444
npm install
@@ -49,7 +49,7 @@ pipeline {
4949
}
5050
stage('Unit Test') {
5151
steps {
52-
dir('./01/src') {
52+
dir('./01/solution') {
5353
sh 'npm test'
5454
}
5555
}
@@ -82,7 +82,7 @@ pipeline {
8282
}
8383
/*diff*/
8484
environment {
85-
VERSION = sh([ script: 'cd ./01/src && npx -c \'echo $npm_package_version\'', returnStdout: true ]).trim()
85+
VERSION = sh([ script: 'cd ./01/solution && npx -c \'echo $npm_package_version\'', returnStdout: true ]).trim()
8686
VERSION_RC = "rc.2"
8787
}
8888
stages {
@@ -99,11 +99,11 @@ pipeline {
9999
stage('Build') {
100100
/*diff*/
101101
environment {
102-
VERSION_SUFFIX = sh(script:'if [ "${RC}" == "false" ] ; then echo -n "${VERSION_RC}+ci.${BUILD_NUMBER}"; else echo -n "${VERSION_RC}"; fi', returnStdout: true)
102+
VERSION_SUFFIX = sh(script:'if [ "${RC}" == "true" ] ; then echo -n "${VERSION_RC}+ci.${BUILD_NUMBER}"; else echo -n "${VERSION_RC}"; fi', returnStdout: true)
103103
}
104104
/*diff*/
105105
steps {
106-
dir('./01/src') {
106+
dir('./01/solution') {
107107
// echo "Building version ${VERSION} with suffix: ${VERSION_RC}"
108108
echo "Building version ${VERSION} with suffix: ${VERSION_SUFFIX}"
109109
sh '''
@@ -115,7 +115,7 @@ pipeline {
115115
}
116116
stage('Unit Test') {
117117
steps {
118-
dir('./01/src') {
118+
dir('./01/solution') {
119119
sh 'npm test'
120120
}
121121
}
@@ -126,7 +126,7 @@ pipeline {
126126
expression { return params.RC }
127127
}
128128
steps {
129-
archiveArtifacts('01/src/app/')
129+
archiveArtifacts('01/solution/app/')
130130
}
131131
}
132132
/*diff*/
@@ -151,7 +151,7 @@ stage('Publish') {
151151
expression { return params.RC }
152152
}
153153
steps {
154-
archiveArtifacts('01/src/app/')
154+
archiveArtifacts('01/solution/app/')
155155
}
156156
}
157157
```
@@ -193,7 +193,7 @@ pipeline {
193193
+ VERSION_SUFFIX = getVersionSuffix()
194194
}
195195
steps {
196-
dir('./01/src') {
196+
dir('./01/solution') {
197197
echo "Building version ${VERSION} with suffix: ${VERSION_SUFFIX}"
198198
sh '''
199199
npm install
@@ -204,7 +204,7 @@ pipeline {
204204
}
205205
stage('Unit Test') {
206206
steps {
207-
dir('./01/src') {
207+
dir('./01/solution') {
208208
sh 'npm test'
209209
}
210210
}
@@ -214,7 +214,7 @@ pipeline {
214214
expression { return params.RC }
215215
}
216216
steps {
217-
archiveArtifacts('01/src/app/')
217+
archiveArtifacts('01/solution/app/')
218218
}
219219
}
220220
}

03-cd/01-jenkins/code.zip

1.43 KB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)