Jenkins
/lib/systemd/system/jenkins.service
- https://github.com/whitespace-se/staffanstorp.se/settings/keys/new
- https://cms.staffanstorp.se/jenkins/manage/credentials/store/system/domain/_/newCredentials
Config
- Nodejs
- https://cms.staffanstorp.se/jenkins/manage/configureTools/
- Add NodeJS
flightplan yarn
https://cms.staffanstorp.se/wp-admin/options-general.php?page=whitespace-headless-cms
Installation
Uncomment the following row to enable the prefix (/jenkins)
Environment="JENKINS_PREFIX=/jenkins" in:
/lib/systemd/system/jenkins.service
https://<USERNAME>:<API-TOKEN>@<JENKINS-URL>/<JENKINS-PREFIX>/job/<JOB-NAME>/buildWithParameters?CLEAN=false&token=<JOB-TOKEN>&cause={DESCRIPTION}
Test url:
curl -X POST http://USER_ID_JENKINS_RECEIVER:TOKEN_OF_USER_ID_JENKINS_RECEIVER@URL_JENKINS_RECEIVER:PORT/job/NAME_OF_JOB/buildWithParameters?token=TOKEN_JOB_JENKINS_RECEIVER
Slack notifications
In order to get slack notifications for a new Jenkins pipeline, add these lines
to the Jenkinsfile right before the finishing }:
post {
failure {
script {
def userIds = slackUserIdsFromCommitters()
def userIdsString = userIds.collect { "<@$it>" }.join(' ')
slackSend(botUser: true, color: 'danger', message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) $userIdsString")
}
}
fixed {
script {
def userIds = slackUserIdsFromCommitters()
def userIdsString = userIds.collect { "<@$it>" }.join(' ')
slackSend(botUser: true, color: 'good', message: "Build Fixed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) $userIdsString")
}
}
}
If the pipeline is being set up on a new Jenkins installation also follow these steps:
- Add a new credential called
slack-tokenof typesecret textand paste in the token found here: https://api.slack.com/apps/A07KJ4EL2GK/install-on-team - Install the plugin
Slack Notification - Go to
Manage Jenkins -> Systemand down to theSlacksection - Set workspace to
white - Set the newly generated credential
- Set default channel to #jenkins-notifications
- Check the
Custom slack app bot userbox