-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test scripted pipeline mounting ~/.m2 (#136)
- Loading branch information
Showing
8 changed files
with
166 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
jenkins-agent-dind/test-fixtures/jobs/test-agent-scripted/Jenkinsfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
node { | ||
// docker can only pull from insecure registries at localhost by default | ||
sh 'docker run --name socat -d --network=host alpine/socat tcp-listen:15432,reuseaddr,fork tcp:jenkins-agent-dind-test-registry:5000' | ||
|
||
sh 'pkgx +java@17 mvn@3 -ntp archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4 -DgroupId=test -DartifactId=test -Dversion=1.0-SNAPSHOT -DinteractiveMode=false' | ||
|
||
dir('test') { | ||
sh 'pkgx +java@17 mvn@3 -ntp clean package' | ||
|
||
docker.image('localhost:15432/jenkins-agent-dind:latest') | ||
.inside('--volume=/var/run/docker.sock:/var/run/docker.sock --group-add=docker --network=host') { | ||
sh 'docker version' | ||
} | ||
|
||
docker.image('localhost:15432/jenkins-agent-dind:latest') | ||
.inside('--volume=/home/jenkins/.pkgx:/home/jenkins/.pkgx --volume=/home/jenkins/.m2:/home/jenkins/.m2 --volume=/var/run/docker.sock:/var/run/docker.sock --group-add=docker --network=host') { | ||
sh 'pkgx +java@17 mvn@3 -o clean package' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
persistence: | ||
enabled: true | ||
agent: | ||
image: | ||
repository: jenkins-agent-dind-test-registry:5000/jenkins-agent-dind | ||
tag: latest | ||
alwaysPullImage: false | ||
args: "" | ||
resources: | ||
requests: | ||
cpu: "2" | ||
memory: "4G" | ||
limits: | ||
cpu: "2" | ||
memory: "4G" | ||
yamlTemplate: | | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
dynamic-hostports: "22" | ||
spec: | ||
hostNetwork: false | ||
automountServiceAccountToken: false | ||
enableServiceLinks: false | ||
# the agent will connect to jenkins using the k8s svc name | ||
# dnsPolicy: Default | ||
restartPolicy: Never | ||
terminationGracePeriodSeconds: 30 | ||
containers: | ||
- name: jnlp | ||
env: | ||
- name: SSHD_ENABLED | ||
value: "true" | ||
ports: | ||
- containerPort: 22 | ||
securityContext: | ||
privileged: true | ||
workingDir: /home/jenkins/agent | ||
terminationMessagePolicy: FallbackToLogsOnError | ||
volumeMounts: | ||
- mountPath: /home/jenkins/agent | ||
name: workspace-volume | ||
- name: podinfo | ||
mountPath: /ssh-command/podinfo | ||
readonly: true | ||
volumes: | ||
- name: workspace-volume | ||
emptyDir: {} | ||
- name: podinfo | ||
downwardAPI: | ||
items: | ||
- path: "sshd-port" | ||
fieldRef: | ||
fieldPath: metadata.annotations['dynamic-hostports.k8s/22'] | ||
- path: "node-fqdn" | ||
fieldRef: | ||
fieldPath: metadata.annotations['dynamic-hostports.k8s/node-fqdn'] | ||
controller: | ||
image: | ||
registry: jenkins-agent-dind-test-registry:5000 | ||
repository: jenkins | ||
tag: latest | ||
installPlugins: false | ||
sidecars: | ||
configAutoReload: | ||
enabled: false | ||
JCasC: | ||
authorizationStrategy: unsecured | ||
configScripts: | ||
jobs: | | ||
jobs: | ||
- script: > | ||
pipelineJob('test-agent-declarative') { | ||
definition { | ||
cps { | ||
sandbox() | ||
script('''\ | ||
{{- readFile "jobs/test-agent-declarative/Jenkinsfile" | nindent 30 }} | ||
'''.stripIndent()) | ||
} | ||
} | ||
} | ||
- script: > | ||
pipelineJob('test-agent-scripted') { | ||
definition { | ||
cps { | ||
sandbox() | ||
script('''\ | ||
{{- readFile "jobs/test-agent-scripted/Jenkinsfile" | nindent 30 }} | ||
'''.stripIndent()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters