Improved Jenkinsfile structure
All checks were successful
JCS-Prod/RSE-Texture/pipeline/head This commit looks good

This commit is contained in:
JackCarterSmith 2021-07-03 15:21:31 +02:00
parent 84e0a0b904
commit 9f98830fce
Signed by: JackCarterSmith
GPG Key ID: DB362B740828F843
2 changed files with 100 additions and 65 deletions

View File

@ -1,49 +1,63 @@
# CMakeLists.txt # CMakeLists.txt
# Written by JackCarterSmith, 2020 # Written by JackCarterSmith, 2020
# This code is released under the RSE license. # This code is released under the RSE license.
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
cmake_policy(VERSION 3.1) cmake_policy(VERSION 3.1)
# define project # define project
project(rse-texture VERSION 1.0.1 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C) if(DEFINED ENV{CI})
set(RSE_TEX_NAME RSE_Texture-${PROJECT_VERSION}) project(rse-texture VERSION 1.0.1.$ENV{CI_BUILD_NUMBER} DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY) set(RSE_TEX_NAME $ENV{CI_OUTPUT_NAME}-${PROJECT_VERSION})
else()
include(CheckIncludeFile) project(rse-texture VERSION 1.0.1 DESCRIPTION "RogueSquadron Extractor - Texture" LANGUAGES C)
include(CheckCSourceCompiles) set(RSE_TEX_NAME RSE_Texture-${PROJECT_VERSION})
endif()
# needed packages configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY)
find_package(ZLIB REQUIRED) include(CheckIncludeFile)
include_directories(${ZLIB_INCLUDE_DIR}) include(CheckCSourceCompiles)
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR}) # needed packages
# define src/headers files find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
FILE(GLOB RSE_TEX_SRCS src/*.c) find_package(PNG REQUIRED)
FILE(GLOB RSE_TEX_HRDS src/*.h) include_directories(${PNG_INCLUDE_DIR})
SOURCE_GROUP("Source Files" FILES ${RSE_TEX_SRCS})
SOURCE_GROUP("Header Files" FILES ${RSE_TEX_HRDS}) # define src/headers files
# begin building RSE-Texture FILE(GLOB RSE_TEX_SRCS src/*.c)
FILE(GLOB RSE_TEX_HRDS src/*.h)
#set(CMAKE_BUILD_TYPE Debug) SOURCE_GROUP("Source Files" FILES ${RSE_TEX_SRCS})
#include_directories(${CMAKE_CURRENT_SOURCE_DIR}) SOURCE_GROUP("Header Files" FILES ${RSE_TEX_HRDS})
add_executable(rse-texture ${RSE_TEX_SRCS} ${RSE_TEX_HRDS})
#set_property(TARGET rse-texture PROPERTY C_STANDARD 99) # begin building RSE-Texture
set_target_properties(rse-texture PROPERTIES OUTPUT_NAME ${RSE_TEX_NAME})
if(MSVC) #set(CMAKE_BUILD_TYPE Debug)
# msvc does not append 'lib' - do it here to have consistent name #include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(rse-texture PROPERTIES PREFIX "lib") add_executable(rse-texture ${RSE_TEX_SRCS} ${RSE_TEX_HRDS})
set_target_properties(rse-texture PROPERTIES IMPORT_PREFIX "lib") #set_property(TARGET rse-texture PROPERTY C_STANDARD 99)
endif() set_target_properties(rse-texture PROPERTIES OUTPUT_NAME ${RSE_TEX_NAME})
target_link_libraries(rse-texture ${ZLIB_LIBRARIES} ${PNG_LIBRARIES}) if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
# install executable set_target_properties(rse-texture PROPERTIES PREFIX "lib")
set_target_properties(rse-texture PROPERTIES IMPORT_PREFIX "lib")
install(TARGETS rse-texture endif()
RUNTIME DESTINATION bin target_link_libraries(rse-texture ${ZLIB_LIBRARIES} ${PNG_LIBRARIES})
# add GPG signature command
#add_custom_command(
# OUTPUT ""
# COMMAND gpg --batch --detach-sign
# -o ${RSE_TEX_NAME}_${CI_SYS_TARGET}.gpg
# ${RSE_TEX_NAME}
# DEPENDS ${RSE_TEX_NAME}
# VERBATIM
#)
# install executable
install(TARGETS rse-texture
RUNTIME DESTINATION bin
) )

55
Jenkinsfile vendored
View File

@ -3,38 +3,58 @@ pipeline {
options { options {
skipDefaultCheckout(true) skipDefaultCheckout(true)
} }
environment {
CI_OUTPUT_NAME = "RSE_Texture"
CI_BUILD_NUMBER = "$BUILD_NUMBER"
}
stages { stages {
stage('Unix-Build') { stage('Prepare') {
steps { steps {
cleanWs() cleanWs()
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
echo 'Build Unix x64_86 release...'
cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']]
} }
} }
stage('Unix-Deploy') { stage('Build') {
steps { steps {
echo 'Deploying solution...' parallel(
sh 'gpg --batch --detach-sign -o build/${JOB_BASE_NAME}_x64_1.0.1-${BUILD_NUMBER}.gpg build/RSE_Texture-1.0.1' linux: {
archiveArtifacts(artifacts: 'build/RSE_Texture-*,build/*.gpg') dir("linux") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']]
}
},
windows: {
dir("windows") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake -D"ZLIB_INCLUDE_DIR=/mnt/cc-libs/mingw64/zlib/1.2.11/include" -D"ZLIB_LIBRARY=/mnt/cc-libs/mingw64/zlib/1.2.11/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=/mnt/cc-libs/mingw64/libpng/1.6.37/include" -D"PNG_LIBRARY=/mnt/cc-libs/mingw64/libpng/1.6.37/lib/libpng.dll.a"', installation: 'latest', steps: [[args: 'all']]
}
}
)
} }
} }
stage('Win-Build') { stage('Deploy') {
steps { steps {
cleanWs() dir("zip_linux") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]]) sh 'cp ../linux/build/${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}* .'
echo 'Build Windows mingw64 release...' }
cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake -D"ZLIB_INCLUDE_DIR=/mnt/cc-libs/mingw64/zlib/1.2.11/include" -D"ZLIB_LIBRARY=/mnt/cc-libs/mingw64/zlib/1.2.11/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=/mnt/cc-libs/mingw64/libpng/1.6.37/include" -D"PNG_LIBRARY=/mnt/cc-libs/mingw64/libpng/1.6.37/lib/libpng.dll.a"', installation: 'latest', steps: [[args: 'all']] dir("zip_win") {
sh 'cp ../windows/build/${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}* /mnt/cc-libs/mingw64/zlib/1.2.11/bin/libzlib.dll /mnt/cc-libs/mingw64/libpng/1.6.37/bin/libpng16.dll .'
}
zip archive: false, dir: 'zip_linux', exclude: '', glob: '', zipFile: 'x64.zip'
sh 'mv x64.zip ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_x64.zip'
zip archive: false, dir: 'zip_win', exclude: '', glob: '', zipFile: 'mingw64.zip'
sh 'mv mingw64.zip ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_mingw64.zip'
} }
} }
stage('Win-Deploy') { stage('Sign') {
steps { steps {
echo 'Deploying solution...' sh 'ls -l'
sh 'gpg --batch --detach-sign -o build/${JOB_BASE_NAME}_mingw64_1.0.1-${BUILD_NUMBER}.gpg build/RSE_Texture-1.0.1.exe' sh 'gpg --batch --detach-sign -o ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_x64.zip.gpg ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_x64.zip'
archiveArtifacts(artifacts: 'build/RSE_Texture-*.exe,build/*.gpg') sh 'gpg --batch --detach-sign -o ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_mingw64.zip.gpg ${CI_OUTPUT_NAME}-1.0.1.${BUILD_NUMBER}_mingw64.zip'
archiveArtifacts(artifacts: '*.zip,*.gpg')
} }
} }
} }
/*
post { post {
always { always {
cleanWs(cleanWhenNotBuilt: false, cleanWs(cleanWhenNotBuilt: false,
@ -43,4 +63,5 @@ pipeline {
notFailBuild: true) notFailBuild: true)
} }
} }
*/
} }