Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pgp signing in Jenkinsfile #1577

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,26 @@ spec:
- name: jnlp
image: 'eclipsecbi/jenkins-jnlp-agent'
volumeMounts:
- mountPath: /home/jenkins/.ssh
name: volume-known-hosts
- name: volume-known-hosts
mountPath: /home/jenkins/.ssh
- name: settings-xml
mountPath: /home/jenkins/.m2/settings.xml
subPath: settings.xml
readOnly: true
- name: m2-repo
mountPath: /home/jenkins/.m2/repository
volumes:
- configMap:
- name: volume-known-hosts
configMap:
name: known-hosts
name: volume-known-hosts
- name: settings-xml
secret:
secretName: m2-secret-dir
items:
- key: settings.xml
path: settings.xml
- name: m2-repo
emptyDir: {}
"""
}
}
Expand All @@ -43,6 +57,16 @@ spec:
GITHUB_API_CREDENTIALS_ID = 'github-bot-token'
}
stages {
stage('initialize PGP') {
steps {
container('container') {
withCredentials([file(credentialsId: 'secret-subkeys.asc', variable: 'KEYRING')]) {
sh 'gpg --batch --import "${KEYRING}"'
sh 'for fpr in $(gpg --list-keys --with-colons | awk -F: \'/fpr:/ {print $10}\' | sort -u); do echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key ${fpr} trust; done'
}
}
}
}
stage('Prepare-environment') {
steps {
container('container') {
Expand All @@ -57,9 +81,11 @@ spec:
stage('Build') {
steps {
container('container') {
withCredentials([string(credentialsId: "${GITHUB_API_CREDENTIALS_ID}", variable: 'GITHUB_API_TOKEN')]) {
wrap([$class: 'Xvnc', useXauthority: true]) {
sh """mvn clean verify -B -fae -Dtycho.disableP2Mirrors=true -Ddownload.cache.skip=true -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Psign -Dmaven.repo.local=$WORKSPACE/.m2/repository -Dgithub.api.token="${GITHUB_API_TOKEN}" """
withCredentials([string(credentialsId: 'gpg-passphrase', variable: 'KEYRING_PASSPHRASE')]) {
withCredentials([string(credentialsId: "${GITHUB_API_CREDENTIALS_ID}", variable: 'GITHUB_API_TOKEN')]) {
wrap([$class: 'Xvnc', useXauthority: true]) {
sh """mvn clean verify -B -fae -Ddownload.cache.skip=true -Dmaven.test.error.ignore=true -Dmaven.test.failure.ignore=true -Psign -Dmaven.repo.local=$WORKSPACE/.m2/repository -Dgithub.api.token="${GITHUB_API_TOKEN}" -Dgpg.passphrase="${KEYRING_PASSPHRASE}" """
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,30 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>sign</id>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-gpg-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>pgpsigner</id>
<goals>
<goal>sign-p2-artifacts</goal>
</goals>
<configuration>
<keyname>9BC06FC97ED4ED26</keyname>
<skipIfJarsigned>true</skipIfJarsigned>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading