For Jenkins freestyle projects see "How to Receive Jenkins Build Notifications in Stride - Freestyle Projects"
Use these settings:
Field | Value |
Kind | Username and Password |
Scope | Global |
Username | Conversation Url you saved (see the previous section) |
Password | Token you saved (see the previous section) |
Id | strideConversationToken |
Description | Anything you want to describe this for future Jenkins administrators |
Open your Jenkins Web Portal.
set +x -u curl -X POST \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer '$STRIDE_TOKEN \ -d "{\"content\":[{\"attrs\":{\"collapsible\":true,\"context\":{\"icon\":{\"label\":\"Jenkins Build Server\",\"url\":\"https://jenkins.io/sites/default/files/jenkins_favicon.ico\"},\"text\":\"Jenkins Build Server - ${JOB_NAME} ${BUILD_DISPLAY_NAME} - BUILD SUCCEEDED\"},\"description\":{\"text\":\"Tag: ${BUILD_TAG} Commit:${GIT_COMMIT}\"},\"details\":[{\"lozenge\":{\"appearance\":\"success\",\"text\":\"BUILD SUCCEEDED\"}},{\"lozenge\":{\"appearance\":\"success\",\"text\":\"${BRANCH_NAME}\"},\"title\":\"Branch\"},{\"lozenge\":{\"appearance\":\"success\",\"text\":\"${BUILD_DISPLAY_NAME}\"},\"title\":\"Build Number\"}],\"link\":{\"url\":\"${RUN_DISPLAY_URL}\"},\"text\":\"${JOB_NAME} - BUILD SUCCEEDED\",\"title\":{\"text\":\"${JOB_NAME} - BUILD SUCCEEDED\",\"user\":{\"icon\":{\"url\":\"https://jenkins.io/sites/default/files/jenkins_favicon.ico\",\"label\":\"BUILD SUCCEEDED\"}}}},\"type\":\"applicationCard\"}],\"type\":\"doc\",\"version\":1}" \ --url $STRIDE_CONVERSATION_URL
set +x -u curl -X POST \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer '$STRIDE_TOKEN \ -d "{\"content\":[{\"attrs\":{\"collapsible\":true,\"context\":{\"icon\":{\"label\":\"Jenkins Build Server\",\"url\":\"https://jenkins.io/sites/default/files/jenkins_favicon.ico\"},\"text\":\"Jenkins Build Server - ${JOB_NAME} ${BUILD_DISPLAY_NAME} - BUILD FAILED\"},\"description\":{\"text\":\"Tag: ${BUILD_TAG} Commit:${GIT_COMMIT}\"},\"details\":[{\"lozenge\":{\"appearance\":\"removed\",\"text\":\"BUILD FAILED\"}},{\"lozenge\":{\"appearance\":\"removed\",\"text\":\"${BRANCH_NAME}\"},\"title\":\"Branch\"},{\"lozenge\":{\"appearance\":\"removed\",\"text\":\"${BUILD_DISPLAY_NAME}\"},\"title\":\"Build Number\"}],\"link\":{\"url\":\"${RUN_DISPLAY_URL}\"},\"text\":\"${JOB_NAME} - BUILD FAILED\",\"title\":{\"text\":\"${JOB_NAME} - BUILD FAILED\",\"user\":{\"icon\":{\"url\":\"https://jenkins.io/images/angry-jenkins_128.png\",\"label\":\"BUILD FAILED\"}}}},\"type\":\"applicationCard\"}],\"type\":\"doc\",\"version\":1}" \ --url $STRIDE_CONVERSATION_URL
set +x -u curl -X POST \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer '$STRIDE_TOKEN \ -d "{\"content\":[{\"attrs\":{\"collapsible\":true,\"context\":{\"icon\":{\"label\":\"Jenkins Build Server\",\"url\":\"https://jenkins.io/sites/default/files/jenkins_favicon.ico\"},\"text\":\"Jenkins Build Server - ${JOB_NAME} ${BUILD_DISPLAY_NAME} - STAGE: ${STAGE_NAME}\"},\"description\":{\"text\":\"Tag: ${BUILD_TAG} Commit:${GIT_COMMIT}\"},\"details\":[{\"lozenge\":{\"appearance\":\"inprogress\",\"text\":\"${STAGE_NAME}\"}},{\"lozenge\":{\"appearance\":\"inprogress\",\"text\":\"${BRANCH_NAME}\"},\"title\":\"Branch\"},{\"lozenge\":{\"appearance\":\"inprogress\",\"text\":\"${BUILD_DISPLAY_NAME}\"},\"title\":\"Build Number\"}],\"link\":{\"url\":\"${RUN_DISPLAY_URL}\"},\"text\":\"${JOB_NAME} - STAGE: ${STAGE_NAME}\",\"title\":{\"text\":\"${JOB_NAME} - STAGE: ${STAGE_NAME}\",\"user\":{\"icon\":{\"url\":\"https://jenkins.io/sites/default/files/jenkins_favicon.ico\",\"label\":\"STAGE: ${STAGE_NAME}\"}}}},\"type\":\"applicationCard\"}],\"type\":\"doc\",\"version\":1}" \ --url $STRIDE_CONVERSATION_URL
https://bitbucket.org/snippets/atlassian/geXnM8#file-Jenkinsfile.groovy - Example of how to use the scripts
pipeline { post{ success{ configFileProvider([configFile(fileId: 'notify_stride.success.sh', variable: 'NOTIFY_SCRIPT')]) { //This injects the credentials for posting to Stride as environment variables inside this code block withCredentials([usernamePassword(credentialsId: 'strideConversationToken', passwordVariable: 'STRIDE_TOKEN', usernameVariable: 'STRIDE_CONVERSATION_URL')]) { //This makes the script executable and then executes it. $NOTIFY_SCRIPT is a env var to the scripts path sh 'chmod +x $NOTIFY_SCRIPT && sh $NOTIFY_SCRIPT' } } } } }
pipeline { post{ failure{ configFileProvider([configFile(fileId: 'notify_stride.success.sh', variable: 'NOTIFY_SCRIPT')]) { //This injects the credentials for posting to Stride as environment variables inside this code block withCredentials([usernamePassword(credentialsId: 'strideConversationToken', passwordVariable: 'STRIDE_TOKEN', usernameVariable: 'STRIDE_CONVERSATION_URL')]) { //This makes the script executable and then executes it. $NOTIFY_SCRIPT is a env var to the scripts path sh 'chmod +x $NOTIFY_SCRIPT && sh $NOTIFY_SCRIPT' } } } } }
pipeline { stages{ stage('Build'){ configFileProvider([configFile(fileId: 'notify_stride.stage.sh', variable: 'NOTIFY_SCRIPT')]) { //This injects the credentials for posting to Stride as environment variables inside this code block withCredentials([usernamePassword(credentialsId: 'strideConversationToken', passwordVariable: 'STRIDE_TOKEN', usernameVariable: 'STRIDE_CONVERSATION_URL')]) { //This makes the script executable and then executes it. $NOTIFY_SCRIPT is a env var to the scripts path sh 'chmod +x $NOTIFY_SCRIPT && sh $NOTIFY_SCRIPT' } } } } }
You can put the stage notification in any stage in your Jenkinsfile, or just make a new stage called 'build started'
if you only want to know when a build kicks off.
???ℜ???
14 comments